From: Martin Stockhammer Date: Fri, 24 Dec 2021 15:29:21 +0000 (+0100) Subject: Refactoring packages for mock classes X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ff068497463318d18b001bf17f04271099cdd5d4;p=archiva.git Refactoring packages for mock classes --- diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/conf/repository-manager.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/conf/repository-manager.xml index 384891f04..8a42a291f 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/conf/repository-manager.xml +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/conf/repository-manager.xml @@ -24,7 +24,7 @@ internal Archiva Managed Internal Repository - file://${appserver.base}/repositories/internal + ${appserver.base}/repositories/internal ${appserver.base}/repositories/internal/.indexer default true @@ -35,7 +35,7 @@ snapshots Archiva Managed Snapshot Repository - file://${appserver.base}/repositories/snapshots + ${appserver.base}/repositories/snapshots .indexer default false @@ -46,7 +46,7 @@ test-repo Test Repository - file://${appserver.base}/test-repo + ${appserver.base}/test-repo default true true diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/mock/repository/RepositoryProviderMock.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/mock/repository/RepositoryProviderMock.java new file mode 100644 index 000000000..a74ae2461 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/mock/repository/RepositoryProviderMock.java @@ -0,0 +1,297 @@ +package org.apache.archiva.consumers.core.mock.repository; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.archiva.configuration.ManagedRepositoryConfiguration; +import org.apache.archiva.configuration.RemoteRepositoryConfiguration; +import org.apache.archiva.configuration.RepositoryGroupConfiguration; +import org.apache.archiva.event.EventHandler; +import org.apache.archiva.repository.base.managed.BasicManagedRepository; +import org.apache.archiva.repository.base.remote.BasicRemoteRepository; +import org.apache.archiva.repository.EditableManagedRepository; +import org.apache.archiva.repository.EditableRemoteRepository; +import org.apache.archiva.repository.EditableRepositoryGroup; +import org.apache.archiva.repository.ManagedRepository; +import org.apache.archiva.repository.base.PasswordCredentials; +import org.apache.archiva.repository.ReleaseScheme; +import org.apache.archiva.repository.RemoteRepository; +import org.apache.archiva.repository.RepositoryCredentials; +import org.apache.archiva.event.Event; +import org.apache.archiva.repository.RepositoryException; +import org.apache.archiva.repository.RepositoryGroup; +import org.apache.archiva.repository.RepositoryProvider; +import org.apache.archiva.repository.RepositoryType; +import org.apache.archiva.repository.event.RepositoryEvent; +import org.apache.archiva.repository.features.ArtifactCleanupFeature; +import org.apache.archiva.repository.features.IndexCreationFeature; +import org.apache.archiva.repository.features.RemoteIndexFeature; +import org.apache.archiva.repository.features.StagingRepositoryFeature; +import org.springframework.stereotype.Service; + +import java.io.IOException; +import java.net.URI; +import java.nio.file.Paths; +import java.time.Duration; +import java.time.Period; +import java.util.HashSet; +import java.util.Set; + +/** + * Just a simple mock class for the repository provider + */ +@Service("mockRepositoryProvider") +public class RepositoryProviderMock implements RepositoryProvider +{ + + private static final Set TYPES = new HashSet<>( ); + + static + { + TYPES.add( RepositoryType.MAVEN ); + TYPES.add( RepositoryType.NPM ); + } + + @Override + public Set provides( ) + { + return TYPES; + } + + @Override + public EditableManagedRepository createManagedInstance( String id, String name ) + { + try { + return BasicManagedRepository.newFilesystemInstance( id, name, Paths.get("target/repositories").resolve(id) ); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + @Override + public EditableRemoteRepository createRemoteInstance( String id, String name ) + { + try { + return BasicRemoteRepository.newFilesystemInstance( id, name, Paths.get("target/remotes") ); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + @Override + public EditableRepositoryGroup createRepositoryGroup( String id, String name ) + { + + return null; + } + + @Override + public ManagedRepository createManagedInstance( ManagedRepositoryConfiguration configuration ) throws RepositoryException + { + BasicManagedRepository managedRepository = null; + try { + managedRepository = BasicManagedRepository.newFilesystemInstance( configuration.getId( ), configuration.getName( ), Paths.get("target/repositories").resolve(configuration.getId()) ); + } catch (IOException e) { + throw new RepositoryException(e); + } + updateManagedInstance( managedRepository, configuration ); + return managedRepository; + } + + + @Override + public void updateManagedInstance( EditableManagedRepository managedRepository, ManagedRepositoryConfiguration configuration ) throws RepositoryException + { + try + { + managedRepository.setName( managedRepository.getPrimaryLocale(), configuration.getName( ) ); + managedRepository.setLocation( new URI( configuration.getLocation( )==null ?"" : configuration.getLocation() ) ); + managedRepository.setBaseUri( new URI( "" ) ); + managedRepository.setBlocksRedeployment( configuration.isBlockRedeployments( ) ); + managedRepository.setDescription( managedRepository.getPrimaryLocale(), configuration.getDescription( ) ); + managedRepository.setLayout( configuration.getLayout( ) ); + managedRepository.setScanned( configuration.isScanned( ) ); + managedRepository.setSchedulingDefinition( configuration.getRefreshCronExpression( ) ); + if (configuration.isReleases()) { + managedRepository.addActiveReleaseScheme( ReleaseScheme.RELEASE ); + } + if (configuration.isSnapshots()) { + managedRepository.addActiveReleaseScheme( ReleaseScheme.SNAPSHOT ); + } + ArtifactCleanupFeature acf = managedRepository.getFeature( ArtifactCleanupFeature.class ).get( ); + acf.setRetentionPeriod( Period.ofDays( configuration.getRetentionPeriod( ) ) ); + acf.setDeleteReleasedSnapshots( configuration.isDeleteReleasedSnapshots( ) ); + acf.setRetentionCount( configuration.getRetentionCount( ) ); + IndexCreationFeature icf = managedRepository.getFeature( IndexCreationFeature.class ).get( ); + icf.setIndexPath( new URI( configuration.getIndexDir( ) ) ); + icf.setSkipPackedIndexCreation( configuration.isSkipPackedIndexCreation( ) ); + StagingRepositoryFeature srf = managedRepository.getFeature( StagingRepositoryFeature.class ).get( ); + srf.setStageRepoNeeded( configuration.isStageRepoNeeded( ) ); + } + catch ( Exception e ) + { + throw new RepositoryException( "Error", e ); + } + + } + + + @Override + public ManagedRepository createStagingInstance( ManagedRepositoryConfiguration configuration ) throws RepositoryException + { + String id = configuration.getId( ) + StagingRepositoryFeature.STAGING_REPO_POSTFIX; + BasicManagedRepository managedRepository = null; + try { + managedRepository = BasicManagedRepository.newFilesystemInstance(id, configuration.getName(), Paths.get("target/repositories").resolve(id)); + } catch (IOException e) { + throw new RepositoryException(e); + } + updateManagedInstance( managedRepository, configuration ); + return managedRepository; + } + + @Override + public RemoteRepository createRemoteInstance( RemoteRepositoryConfiguration configuration ) throws RepositoryException + { + BasicRemoteRepository remoteRepository = null; + try { + remoteRepository = BasicRemoteRepository.newFilesystemInstance( configuration.getId( ), configuration.getName( ), Paths.get("target/remotes") ); + } catch (IOException e) { + throw new RepositoryException(e); + } + updateRemoteInstance( remoteRepository, configuration ); + return remoteRepository; + } + + @SuppressWarnings("unchecked") + @Override + public void updateRemoteInstance( EditableRemoteRepository remoteRepository, RemoteRepositoryConfiguration configuration ) throws RepositoryException + { + try + { + remoteRepository.setName( remoteRepository.getPrimaryLocale(), configuration.getName( ) ); + remoteRepository.setBaseUri( new URI( "" ) ); + remoteRepository.setDescription( remoteRepository.getPrimaryLocale(), configuration.getDescription( ) ); + remoteRepository.setLayout( configuration.getLayout( ) ); + remoteRepository.setSchedulingDefinition( configuration.getRefreshCronExpression( ) ); + remoteRepository.setCheckPath( configuration.getCheckPath( ) ); + remoteRepository.setExtraHeaders( configuration.getExtraHeaders( ) ); + remoteRepository.setExtraParameters( configuration.getExtraParameters( ) ); + remoteRepository.setTimeout( Duration.ofSeconds( configuration.getTimeout( ) ) ); + char[] pwd = configuration.getPassword()==null ? "".toCharArray() : configuration.getPassword().toCharArray(); + remoteRepository.setCredentials( new PasswordCredentials( configuration.getUsername( ), pwd ) ); + remoteRepository.setLocation( new URI( configuration.getUrl( )==null ? "" : configuration.getUrl() ) ); + RemoteIndexFeature rif = remoteRepository.getFeature( RemoteIndexFeature.class ).get( ); + rif.setDownloadRemoteIndexOnStartup( configuration.isDownloadRemoteIndexOnStartup( ) ); + rif.setDownloadRemoteIndex( configuration.isDownloadRemoteIndex( ) ); + rif.setIndexUri( new URI( configuration.getIndexDir( ) ) ); + rif.setDownloadTimeout( Duration.ofSeconds( configuration.getRemoteDownloadTimeout( ) ) ); + rif.setProxyId( configuration.getRemoteDownloadNetworkProxyId( ) ); + } + catch ( Exception e ) + { + throw new RepositoryException( "Error", e ); + } + + } + + @Override + public RepositoryGroup createRepositoryGroup( RepositoryGroupConfiguration configuration ) throws RepositoryException + { + return null; + } + + @Override + public void updateRepositoryGroupInstance( EditableRepositoryGroup repositoryGroup, RepositoryGroupConfiguration configuration ) throws RepositoryException + { + + } + + @Override + public ManagedRepositoryConfiguration getManagedConfiguration( ManagedRepository managedRepository ) + { + ManagedRepositoryConfiguration configuration = new ManagedRepositoryConfiguration( ); + configuration.setId( managedRepository.getId( ) ); + configuration.setName(managedRepository.getName()); + configuration.setLocation( managedRepository.getLocation( ) == null ? "" : managedRepository.getLocation().toString( ) ); + configuration.setBlockRedeployments( managedRepository.blocksRedeployments( ) ); + configuration.setDescription( managedRepository.getDescription( ) ); + configuration.setScanned( managedRepository.isScanned( ) ); + configuration.setRefreshCronExpression( managedRepository.getSchedulingDefinition( ) ); + configuration.setReleases( managedRepository.getActiveReleaseSchemes().contains(ReleaseScheme.RELEASE) ); + configuration.setSnapshots( managedRepository.getActiveReleaseSchemes().contains(ReleaseScheme.SNAPSHOT) ); + configuration.setLayout( managedRepository.getLayout() ); + ArtifactCleanupFeature acf = managedRepository.getFeature( ArtifactCleanupFeature.class ).get( ); + configuration.setRetentionPeriod( acf.getRetentionPeriod( ).getDays( ) ); + configuration.setDeleteReleasedSnapshots( acf.isDeleteReleasedSnapshots( ) ); + configuration.setRetentionCount( acf.getRetentionCount( ) ); + IndexCreationFeature icf = managedRepository.getFeature( IndexCreationFeature.class ).get( ); + configuration.setSkipPackedIndexCreation( icf.isSkipPackedIndexCreation( ) ); + configuration.setIndexDir( icf.getIndexPath( ) == null ? "" : icf.getIndexPath().toString( ) ); + StagingRepositoryFeature srf = managedRepository.getFeature( StagingRepositoryFeature.class ).get( ); + configuration.setStageRepoNeeded( srf.isStageRepoNeeded( ) ); + return configuration; + } + + @Override + public RepositoryGroupConfiguration getRepositoryGroupConfiguration( RepositoryGroup repositoryGroup ) throws RepositoryException + { + return null; + } + + @Override + public void addRepositoryEventHandler( EventHandler eventHandler ) + { + // do nothing + } + + + @Override + public RemoteRepositoryConfiguration getRemoteConfiguration( RemoteRepository remoteRepository ) + { + RemoteRepositoryConfiguration configuration = new RemoteRepositoryConfiguration( ); + configuration.setId( remoteRepository.getId( ) ); + configuration.setName( remoteRepository.getName( ) ); + configuration.setDescription( remoteRepository.getDescription( ) ); + configuration.setLayout( remoteRepository.getLayout( ) ); + configuration.setRefreshCronExpression( remoteRepository.getSchedulingDefinition( ) ); + configuration.setCheckPath( remoteRepository.getCheckPath( ) ); + configuration.setExtraHeaders( remoteRepository.getExtraHeaders( ) ); + configuration.setExtraParameters( remoteRepository.getExtraParameters( ) ); + configuration.setTimeout( (int) remoteRepository.getTimeout( ).getSeconds( ) ); + RepositoryCredentials creds = remoteRepository.getLoginCredentials( ); + if (creds!=null) + { + PasswordCredentials pwdCreds = (PasswordCredentials) creds; + configuration.setUsername( pwdCreds.getUsername( ) ); + configuration.setPassword( new String( pwdCreds.getPassword( ) ) ); + } + configuration.setUrl( remoteRepository.getLocation( ) == null ? "" : remoteRepository.getLocation().toString( ) ); + RemoteIndexFeature rif = remoteRepository.getFeature( RemoteIndexFeature.class ).get( ); + configuration.setDownloadRemoteIndex( rif.isDownloadRemoteIndex( ) ); + configuration.setDownloadRemoteIndexOnStartup( rif.isDownloadRemoteIndexOnStartup( ) ); + configuration.setIndexDir( rif.getIndexUri( )==null ? "" : rif.getIndexUri().toString( ) ); + configuration.setRemoteDownloadNetworkProxyId( rif.getProxyId( ) ); + return configuration; + } + + @Override + public void handle(Event event) { + + } +} diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/repository/mock/RepositoryProviderMock.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/repository/mock/RepositoryProviderMock.java deleted file mode 100644 index 0c8f71f14..000000000 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/repository/mock/RepositoryProviderMock.java +++ /dev/null @@ -1,298 +0,0 @@ -package org.apache.archiva.repository.mock; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.archiva.configuration.ManagedRepositoryConfiguration; -import org.apache.archiva.configuration.RemoteRepositoryConfiguration; -import org.apache.archiva.configuration.RepositoryGroupConfiguration; -import org.apache.archiva.event.EventHandler; -import org.apache.archiva.repository.base.managed.BasicManagedRepository; -import org.apache.archiva.repository.base.remote.BasicRemoteRepository; -import org.apache.archiva.repository.EditableManagedRepository; -import org.apache.archiva.repository.EditableRemoteRepository; -import org.apache.archiva.repository.EditableRepositoryGroup; -import org.apache.archiva.repository.ManagedRepository; -import org.apache.archiva.repository.base.PasswordCredentials; -import org.apache.archiva.repository.ReleaseScheme; -import org.apache.archiva.repository.RemoteRepository; -import org.apache.archiva.repository.RepositoryCredentials; -import org.apache.archiva.event.Event; -import org.apache.archiva.repository.RepositoryException; -import org.apache.archiva.repository.RepositoryGroup; -import org.apache.archiva.repository.RepositoryProvider; -import org.apache.archiva.repository.RepositoryType; -import org.apache.archiva.repository.event.RepositoryEvent; -import org.apache.archiva.repository.features.ArtifactCleanupFeature; -import org.apache.archiva.repository.features.IndexCreationFeature; -import org.apache.archiva.repository.features.RemoteIndexFeature; -import org.apache.archiva.repository.features.StagingRepositoryFeature; -import org.springframework.stereotype.Service; - -import java.io.IOException; -import java.net.URI; -import java.nio.file.Paths; -import java.time.Duration; -import java.time.Period; -import java.util.HashSet; -import java.util.Set; - -/** - * Just a simple mock class for the repository provider - */ -@Service("mockRepositoryProvider") -public class RepositoryProviderMock implements RepositoryProvider -{ - - private static final Set TYPES = new HashSet<>( ); - - static - { - TYPES.add( RepositoryType.MAVEN ); - TYPES.add( RepositoryType.NPM ); - } - - @Override - public Set provides( ) - { - return TYPES; - } - - @Override - public EditableManagedRepository createManagedInstance( String id, String name ) - { - try { - return BasicManagedRepository.newFilesystemInstance( id, name, Paths.get("target/repositories").resolve(id) ); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - @Override - public EditableRemoteRepository createRemoteInstance( String id, String name ) - { - try { - return BasicRemoteRepository.newFilesystemInstance( id, name, Paths.get("target/remotes") ); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - @Override - public EditableRepositoryGroup createRepositoryGroup( String id, String name ) - { - - return null; - } - - @Override - public ManagedRepository createManagedInstance( ManagedRepositoryConfiguration configuration ) throws RepositoryException - { - BasicManagedRepository managedRepository = null; - try { - managedRepository = BasicManagedRepository.newFilesystemInstance( configuration.getId( ), configuration.getName( ), Paths.get("target/repositories").resolve(configuration.getId()) ); - } catch (IOException e) { - throw new RepositoryException(e); - } - updateManagedInstance( managedRepository, configuration ); - return managedRepository; - } - - - @Override - public void updateManagedInstance( EditableManagedRepository managedRepository, ManagedRepositoryConfiguration configuration ) throws RepositoryException - { - try - { - managedRepository.setName( managedRepository.getPrimaryLocale(), configuration.getName( ) ); - managedRepository.setLocation( new URI( configuration.getLocation( )==null ?"" : configuration.getLocation() ) ); - managedRepository.setBaseUri( new URI( "" ) ); - managedRepository.setBlocksRedeployment( configuration.isBlockRedeployments( ) ); - managedRepository.setDescription( managedRepository.getPrimaryLocale(), configuration.getDescription( ) ); - managedRepository.setLayout( configuration.getLayout( ) ); - managedRepository.setScanned( configuration.isScanned( ) ); - managedRepository.setSchedulingDefinition( configuration.getRefreshCronExpression( ) ); - if (configuration.isReleases()) { - managedRepository.addActiveReleaseScheme( ReleaseScheme.RELEASE ); - } - if (configuration.isSnapshots()) { - managedRepository.addActiveReleaseScheme( ReleaseScheme.SNAPSHOT ); - } - ArtifactCleanupFeature acf = managedRepository.getFeature( ArtifactCleanupFeature.class ).get( ); - acf.setRetentionPeriod( Period.ofDays( configuration.getRetentionPeriod( ) ) ); - acf.setDeleteReleasedSnapshots( configuration.isDeleteReleasedSnapshots( ) ); - acf.setRetentionCount( configuration.getRetentionCount( ) ); - IndexCreationFeature icf = managedRepository.getFeature( IndexCreationFeature.class ).get( ); - icf.setIndexPath( new URI( configuration.getIndexDir( ) ) ); - icf.setSkipPackedIndexCreation( configuration.isSkipPackedIndexCreation( ) ); - StagingRepositoryFeature srf = managedRepository.getFeature( StagingRepositoryFeature.class ).get( ); - srf.setStageRepoNeeded( configuration.isStageRepoNeeded( ) ); - } - catch ( Exception e ) - { - throw new RepositoryException( "Error", e ); - } - - } - - - @Override - public ManagedRepository createStagingInstance( ManagedRepositoryConfiguration configuration ) throws RepositoryException - { - String id = configuration.getId( ) + StagingRepositoryFeature.STAGING_REPO_POSTFIX; - BasicManagedRepository managedRepository = null; - try { - managedRepository = BasicManagedRepository.newFilesystemInstance(id, configuration.getName(), Paths.get("target/repositories").resolve(id)); - } catch (IOException e) { - throw new RepositoryException(e); - } - updateManagedInstance( managedRepository, configuration ); - return managedRepository; - } - - @Override - public RemoteRepository createRemoteInstance( RemoteRepositoryConfiguration configuration ) throws RepositoryException - { - BasicRemoteRepository remoteRepository = null; - try { - remoteRepository = BasicRemoteRepository.newFilesystemInstance( configuration.getId( ), configuration.getName( ), Paths.get("target/remotes") ); - } catch (IOException e) { - throw new RepositoryException(e); - } - updateRemoteInstance( remoteRepository, configuration ); - return remoteRepository; - } - - @SuppressWarnings("unchecked") - @Override - public void updateRemoteInstance( EditableRemoteRepository remoteRepository, RemoteRepositoryConfiguration configuration ) throws RepositoryException - { - try - { - remoteRepository.setName( remoteRepository.getPrimaryLocale(), configuration.getName( ) ); - remoteRepository.setBaseUri( new URI( "" ) ); - remoteRepository.setDescription( remoteRepository.getPrimaryLocale(), configuration.getDescription( ) ); - remoteRepository.setLayout( configuration.getLayout( ) ); - remoteRepository.setSchedulingDefinition( configuration.getRefreshCronExpression( ) ); - remoteRepository.setCheckPath( configuration.getCheckPath( ) ); - remoteRepository.setExtraHeaders( configuration.getExtraHeaders( ) ); - remoteRepository.setExtraParameters( configuration.getExtraParameters( ) ); - remoteRepository.setTimeout( Duration.ofSeconds( configuration.getTimeout( ) ) ); - char[] pwd = configuration.getPassword()==null ? "".toCharArray() : configuration.getPassword().toCharArray(); - remoteRepository.setCredentials( new PasswordCredentials( configuration.getUsername( ), pwd ) ); - remoteRepository.setLocation( new URI( configuration.getUrl( )==null ? "" : configuration.getUrl() ) ); - RemoteIndexFeature rif = remoteRepository.getFeature( RemoteIndexFeature.class ).get( ); - rif.setDownloadRemoteIndexOnStartup( configuration.isDownloadRemoteIndexOnStartup( ) ); - rif.setDownloadRemoteIndex( configuration.isDownloadRemoteIndex( ) ); - rif.setIndexUri( new URI( configuration.getIndexDir( ) ) ); - rif.setDownloadTimeout( Duration.ofSeconds( configuration.getRemoteDownloadTimeout( ) ) ); - rif.setProxyId( configuration.getRemoteDownloadNetworkProxyId( ) ); - } - catch ( Exception e ) - { - throw new RepositoryException( "Error", e ); - } - - } - - @Override - public RepositoryGroup createRepositoryGroup( RepositoryGroupConfiguration configuration ) throws RepositoryException - { - return null; - } - - @Override - public void updateRepositoryGroupInstance( EditableRepositoryGroup repositoryGroup, RepositoryGroupConfiguration configuration ) throws RepositoryException - { - - } - - @Override - public ManagedRepositoryConfiguration getManagedConfiguration( ManagedRepository managedRepository ) - { - ManagedRepositoryConfiguration configuration = new ManagedRepositoryConfiguration( ); - configuration.setId( managedRepository.getId( ) ); - configuration.setName(managedRepository.getName()); - configuration.setLocation( managedRepository.getLocation( ) == null ? "" : managedRepository.getLocation().toString( ) ); - configuration.setBlockRedeployments( managedRepository.blocksRedeployments( ) ); - configuration.setDescription( managedRepository.getDescription( ) ); - configuration.setScanned( managedRepository.isScanned( ) ); - configuration.setRefreshCronExpression( managedRepository.getSchedulingDefinition( ) ); - configuration.setReleases( managedRepository.getActiveReleaseSchemes().contains(ReleaseScheme.RELEASE) ); - configuration.setSnapshots( managedRepository.getActiveReleaseSchemes().contains(ReleaseScheme.SNAPSHOT) ); - configuration.setLayout( managedRepository.getLayout() ); - ArtifactCleanupFeature acf = managedRepository.getFeature( ArtifactCleanupFeature.class ).get( ); - configuration.setRetentionPeriod( acf.getRetentionPeriod( ).getDays( ) ); - configuration.setDeleteReleasedSnapshots( acf.isDeleteReleasedSnapshots( ) ); - configuration.setRetentionCount( acf.getRetentionCount( ) ); - IndexCreationFeature icf = managedRepository.getFeature( IndexCreationFeature.class ).get( ); - configuration.setSkipPackedIndexCreation( icf.isSkipPackedIndexCreation( ) ); - configuration.setIndexDir( icf.getIndexPath( ) == null ? "" : icf.getIndexPath().toString( ) ); - StagingRepositoryFeature srf = managedRepository.getFeature( StagingRepositoryFeature.class ).get( ); - configuration.setStageRepoNeeded( srf.isStageRepoNeeded( ) ); - return configuration; - } - - @Override - public RepositoryGroupConfiguration getRepositoryGroupConfiguration( RepositoryGroup repositoryGroup ) throws RepositoryException - { - return null; - } - - @Override - public void addRepositoryEventHandler( EventHandler eventHandler ) - { - // do nothing - } - - - @Override - public RemoteRepositoryConfiguration getRemoteConfiguration( RemoteRepository remoteRepository ) - { - RemoteRepositoryConfiguration configuration = new RemoteRepositoryConfiguration( ); - configuration.setId( remoteRepository.getId( ) ); - configuration.setName( remoteRepository.getName( ) ); - configuration.setDescription( remoteRepository.getDescription( ) ); - configuration.setLayout( remoteRepository.getLayout( ) ); - configuration.setRefreshCronExpression( remoteRepository.getSchedulingDefinition( ) ); - configuration.setCheckPath( remoteRepository.getCheckPath( ) ); - configuration.setExtraHeaders( remoteRepository.getExtraHeaders( ) ); - configuration.setExtraParameters( remoteRepository.getExtraParameters( ) ); - configuration.setTimeout( (int) remoteRepository.getTimeout( ).getSeconds( ) ); - RepositoryCredentials creds = remoteRepository.getLoginCredentials( ); - if (creds!=null) - { - PasswordCredentials pwdCreds = (PasswordCredentials) creds; - configuration.setUsername( pwdCreds.getUsername( ) ); - configuration.setPassword( new String( pwdCreds.getPassword( ) ) ); - } - configuration.setUrl( remoteRepository.getLocation( ) == null ? "" : remoteRepository.getLocation().toString( ) ); - RemoteIndexFeature rif = remoteRepository.getFeature( RemoteIndexFeature.class ).get( ); - configuration.setDownloadRemoteIndex( rif.isDownloadRemoteIndex( ) ); - configuration.setDownloadRemoteIndexOnStartup( rif.isDownloadRemoteIndexOnStartup( ) ); - configuration.setIndexDir( rif.getIndexUri( )==null ? "" : rif.getIndexUri().toString( ) ); - configuration.setRemoteDownloadNetworkProxyId( rif.getProxyId( ) ); - return configuration; - } - - @Override - public void handle(Event event) { - - } -} diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/spring-context-purge-consumer-test.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/spring-context-purge-consumer-test.xml index 2f1521abc..0657f9551 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/spring-context-purge-consumer-test.xml +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/spring-context-purge-consumer-test.xml @@ -28,7 +28,7 @@ default-lazy-init="true"> - + diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/spring-context.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/spring-context.xml index 1e1030ff0..a0014e153 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/spring-context.xml +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/spring-context.xml @@ -27,7 +27,7 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd" default-lazy-init="true"> - + diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/metadata/audit/TestAuditListener.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/metadata/audit/TestAuditListener.java deleted file mode 100644 index 7f4a9538d..000000000 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/metadata/audit/TestAuditListener.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.apache.archiva.metadata.audit; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.archiva.metadata.model.facets.AuditEvent; - -import java.util.ArrayList; -import java.util.List; - -public class TestAuditListener - implements AuditListener -{ - public List getEvents() - { - return events; - } - - private List events = new ArrayList<>(); - - @Override - public void auditEvent( AuditEvent event ) - { - events.add( event ); - } -} 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 73f181f39..22d7c58a5 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 @@ -35,7 +35,7 @@ import org.apache.archiva.repository.RepositoryException; import org.apache.archiva.repository.base.ArchivaRepositoryRegistry; import org.apache.archiva.repository.base.RepositoryHandlerDependencies; import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner; -import org.apache.archiva.webdav.httpunit.MkColMethodWebRequest; +import org.apache.archiva.webdav.mock.httpunit.MkColMethodWebRequest; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletDeployTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletDeployTest.java index 3b170401a..e29190aac 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletDeployTest.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletDeployTest.java @@ -22,7 +22,7 @@ package org.apache.archiva.webdav; import com.gargoylesoftware.htmlunit.WebRequest; import com.gargoylesoftware.htmlunit.WebResponse; import org.apache.archiva.configuration.ManagedRepositoryConfiguration; -import org.apache.archiva.webdav.httpunit.MkColMethodWebRequest; +import org.apache.archiva.webdav.mock.httpunit.MkColMethodWebRequest; import org.junit.After; import org.junit.Before; import org.junit.Test; diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletSecurityTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletSecurityTest.java index 6713786ed..36e1f1dca 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletSecurityTest.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletSecurityTest.java @@ -34,7 +34,7 @@ import org.apache.archiva.redback.system.SecuritySession; import org.apache.archiva.redback.users.User; import org.apache.archiva.redback.users.memory.SimpleUser; import org.apache.archiva.repository.RepositoryRegistry; -import org.apache.archiva.metadata.audit.TestAuditListener; +import org.apache.archiva.webdav.mock.metadata.audit.TestAuditListener; import org.apache.archiva.repository.base.group.RepositoryGroupHandler; import org.apache.archiva.security.ServletAuthenticator; import org.apache.archiva.security.common.ArchivaRoleConstants; diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/httpunit/MkColMethodWebRequest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/httpunit/MkColMethodWebRequest.java deleted file mode 100644 index 7702a9ce1..000000000 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/httpunit/MkColMethodWebRequest.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.apache.archiva.webdav.httpunit; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - - -import com.gargoylesoftware.htmlunit.WebRequest; - -import java.net.URL; - -/** - * MkColMethodWebRequest - * See RFC-2518 Section 8.3 - */ -public class MkColMethodWebRequest - extends WebRequest -{ - public MkColMethodWebRequest( String urlString ) - throws Exception - { - super( new URL( urlString ) ); - } - - -} diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/mock/httpunit/MkColMethodWebRequest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/mock/httpunit/MkColMethodWebRequest.java new file mode 100644 index 000000000..1e091bfff --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/mock/httpunit/MkColMethodWebRequest.java @@ -0,0 +1,40 @@ +package org.apache.archiva.webdav.mock.httpunit; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +import com.gargoylesoftware.htmlunit.WebRequest; + +import java.net.URL; + +/** + * MkColMethodWebRequest + * See RFC-2518 Section 8.3 + */ +public class MkColMethodWebRequest + extends WebRequest +{ + public MkColMethodWebRequest( String urlString ) + throws Exception + { + super( new URL( urlString ) ); + } + + +} diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/mock/metadata/audit/TestAuditListener.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/mock/metadata/audit/TestAuditListener.java new file mode 100644 index 000000000..f8d0af173 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/mock/metadata/audit/TestAuditListener.java @@ -0,0 +1,42 @@ +package org.apache.archiva.webdav.mock.metadata.audit; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.archiva.metadata.audit.AuditListener; +import org.apache.archiva.metadata.model.facets.AuditEvent; + +import java.util.ArrayList; +import java.util.List; + +public class TestAuditListener + implements AuditListener +{ + public List getEvents() + { + return events; + } + + private List events = new ArrayList<>(); + + @Override + public void auditEvent( AuditEvent event ) + { + events.add( event ); + } +} diff --git a/archiva-modules/metadata/metadata-store-provider/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/DefaultCassandraArchivaManager.java b/archiva-modules/metadata/metadata-store-provider/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/DefaultCassandraArchivaManager.java index 720f1a912..df53f600b 100644 --- a/archiva-modules/metadata/metadata-store-provider/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/DefaultCassandraArchivaManager.java +++ b/archiva-modules/metadata/metadata-store-provider/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/DefaultCassandraArchivaManager.java @@ -180,7 +180,6 @@ public class DefaultCassandraArchivaManager List hostNames = new ArrayList<>( ); hostNames.add( cassandraHost + ":" + cassandraPort ); - System.out.println( "Contact point: " + cassandraHost + ":" + cassandraPort ); configLoader = DriverConfigLoader.programmaticBuilder( ) diff --git a/archiva-modules/metadata/metadata-store-provider/metadata-store-cassandra/src/test/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepositoryTest.java b/archiva-modules/metadata/metadata-store-provider/metadata-store-cassandra/src/test/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepositoryTest.java index ccdb3039f..a6c4bf0fe 100644 --- a/archiva-modules/metadata/metadata-store-provider/metadata-store-cassandra/src/test/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepositoryTest.java +++ b/archiva-modules/metadata/metadata-store-provider/metadata-store-cassandra/src/test/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepositoryTest.java @@ -95,9 +95,7 @@ public class CassandraMetadataRepositoryTest throws Exception { cTime = System.currentTimeMillis( ); - System.err.println( "Setting up - "+(testNum++) + " - " + testInfo.getDisplayName() + " - 0ms"); super.setUp(); - System.err.println( "Setting up - " + testInfo.getDisplayName( ) + " - " + (System.currentTimeMillis( ) - cTime) +"ms"); assertMaxTries =1; assertRetrySleepMs=10; @@ -126,7 +124,6 @@ public class CassandraMetadataRepositoryTest { clearReposAndNamespace( cassandraArchivaManager, clearedTables ); } - System.err.println( "Finished setting up - "+testInfo.getDisplayName() + " - " + (System.currentTimeMillis( ) - cTime) +"ms"); } /** @@ -165,10 +162,8 @@ public class CassandraMetadataRepositoryTest public void shutdown(TestInfo testInfo) throws Exception { - System.err.println( "Shutting down - " + (testNum-1) + " - " + testInfo.getDisplayName( ) + " - " + ( System.currentTimeMillis( ) - cTime ) +"ms"); clearReposAndNamespace( cassandraArchivaManager, clearedTables ); super.tearDown(); - System.err.println( "Shutting down finished - " + testInfo.getDisplayName( ) + " - " + ( System.currentTimeMillis( ) - cTime ) +"ms"); } static void clearReposAndNamespace( final CassandraArchivaManager cassandraArchivaManager, final AtomicBoolean clearedFlag )