From: Olivier Lamy Date: Tue, 4 Oct 2011 21:14:27 +0000 (+0000) Subject: [MRM-1332] remove database scanning configuration and handle upgrade. X-Git-Tag: archiva-1.4-M1~84 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=46840f3c31bb81b4088473d49a74c8f1a519aa7a;p=archiva.git [MRM-1332] remove database scanning configuration and handle upgrade. ensure some consumers are here and remove db consumers. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1178954 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java b/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java index f5ae29540..afa12c4fd 100644 --- a/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java +++ b/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java @@ -52,6 +52,7 @@ import javax.inject.Named; import java.io.File; import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -136,12 +137,12 @@ public class DefaultArchivaConfiguration /** * Configuration Listeners we've registered. */ - private Set listeners = new HashSet(); + private Set listeners = new HashSet( ); /** * Registry Listeners we've registered. */ - private Set registryListeners = new HashSet(); + private Set registryListeners = new HashSet( ); /** * Boolean to help determine if the configuration exists as a result of pulling in @@ -151,16 +152,16 @@ public class DefaultArchivaConfiguration private static final String KEY = "org.apache.archiva"; - public Configuration getConfiguration() + public Configuration getConfiguration( ) { - return loadConfiguration(); + return loadConfiguration( ); } - private synchronized Configuration loadConfiguration() + private synchronized Configuration loadConfiguration( ) { if ( configuration == null ) { - configuration = load(); + configuration = load( ); configuration = unescapeExpressions( configuration ); if ( isConfigurationDefaulted ) { @@ -172,113 +173,113 @@ public class DefaultArchivaConfiguration } @SuppressWarnings( "unchecked" ) - private Configuration load() + private Configuration load( ) { // TODO: should this be the same as section? make sure unnamed sections still work (eg, sys properties) Registry subset = registry.getSubset( KEY ); if ( subset.getString( "version" ) == null ) { // a little autodetection of v1, even if version is omitted (this was previously allowed) - if ( subset.getSubset( "repositoryScanning" ).isEmpty() ) + if ( subset.getSubset( "repositoryScanning" ).isEmpty( ) ) { // only for empty, or v < 1 - subset = readDefaultConfiguration(); + subset = readDefaultConfiguration( ); } } - Configuration config = new ConfigurationRegistryReader().read( subset ); + Configuration config = new ConfigurationRegistryReader( ).read( subset ); - config.getRepositoryGroups(); - config.getRepositoryGroupsAsMap(); - if ( !config.getRepositories().isEmpty() ) + config.getRepositoryGroups( ); + config.getRepositoryGroupsAsMap( ); + if ( !config.getRepositories( ).isEmpty( ) ) { - for ( Iterator i = config.getRepositories().iterator(); i.hasNext(); ) + for ( Iterator i = config.getRepositories( ).iterator( ); i.hasNext( ); ) { - V1RepositoryConfiguration r = i.next(); - r.setScanned( r.isIndexed() ); + V1RepositoryConfiguration r = i.next( ); + r.setScanned( r.isIndexed( ) ); - if ( StringUtils.startsWith( r.getUrl(), "file://" ) ) + if ( StringUtils.startsWith( r.getUrl( ), "file://" ) ) { - r.setLocation( r.getUrl().substring( 7 ) ); + r.setLocation( r.getUrl( ).substring( 7 ) ); config.addManagedRepository( r ); } - else if ( StringUtils.startsWith( r.getUrl(), "file:" ) ) + else if ( StringUtils.startsWith( r.getUrl( ), "file:" ) ) { - r.setLocation( r.getUrl().substring( 5 ) ); + r.setLocation( r.getUrl( ).substring( 5 ) ); config.addManagedRepository( r ); } - else if ( StringUtils.isEmpty( r.getUrl() ) ) + else if ( StringUtils.isEmpty( r.getUrl( ) ) ) { // in case of empty url we can consider it as a managed one // check if location is null //file://${appserver.base}/repositories/${id} - if ( StringUtils.isEmpty( r.getLocation() ) ) + if ( StringUtils.isEmpty( r.getLocation( ) ) ) { - r.setLocation( "file://${appserver.base}/repositories/" + r.getId() ); + r.setLocation( "file://${appserver.base}/repositories/" + r.getId( ) ); } config.addManagedRepository( r ); } else { - RemoteRepositoryConfiguration repo = new RemoteRepositoryConfiguration(); - repo.setId( r.getId() ); - repo.setLayout( r.getLayout() ); - repo.setName( r.getName() ); - repo.setUrl( r.getUrl() ); + RemoteRepositoryConfiguration repo = new RemoteRepositoryConfiguration( ); + repo.setId( r.getId( ) ); + repo.setLayout( r.getLayout( ) ); + repo.setName( r.getName( ) ); + repo.setUrl( r.getUrl( ) ); config.addRemoteRepository( repo ); } } // Prevent duplicate repositories from showing up. - config.getRepositories().clear(); + config.getRepositories( ).clear( ); registry.removeSubset( KEY + ".repositories" ); } - if ( !CollectionUtils.isEmpty( config.getRemoteRepositories() ) ) + if ( !CollectionUtils.isEmpty( config.getRemoteRepositories( ) ) ) { - List remoteRepos = config.getRemoteRepositories(); + List remoteRepos = config.getRemoteRepositories( ); for ( RemoteRepositoryConfiguration repo : remoteRepos ) { // [MRM-582] Remote Repositories with empty and fields shouldn't be created in configuration. - if ( StringUtils.isBlank( repo.getUsername() ) ) + if ( StringUtils.isBlank( repo.getUsername( ) ) ) { repo.setUsername( null ); } - if ( StringUtils.isBlank( repo.getPassword() ) ) + if ( StringUtils.isBlank( repo.getPassword( ) ) ) { repo.setPassword( null ); } } } - if ( !config.getProxyConnectors().isEmpty() ) + if ( !config.getProxyConnectors( ).isEmpty( ) ) { // Fix Proxy Connector Settings. - List proxyConnectorList = new ArrayList(); + List proxyConnectorList = new ArrayList( ); // Create a copy of the list to read from (to prevent concurrent modification exceptions) - proxyConnectorList.addAll( config.getProxyConnectors() ); + proxyConnectorList.addAll( config.getProxyConnectors( ) ); // Remove the old connector list. - config.getProxyConnectors().clear(); + config.getProxyConnectors( ).clear( ); for ( ProxyConnectorConfiguration connector : proxyConnectorList ) { // Fix policies boolean connectorValid = true; - Map policies = new HashMap(); + Map policies = new HashMap( ); // Make copy of policies - policies.putAll( connector.getPolicies() ); + policies.putAll( connector.getPolicies( ) ); // Clear out policies - connector.getPolicies().clear(); + connector.getPolicies( ).clear( ); // Work thru policies. cleaning them up. - for ( Entry entry : policies.entrySet() ) + for ( Entry entry : policies.entrySet( ) ) { - String policyId = entry.getKey(); - String setting = entry.getValue(); + String policyId = entry.getKey( ); + String setting = entry.getValue( ); // Upgrade old policy settings. if ( "releases".equals( policyId ) || "snapshots".equals( policyId ) ) @@ -316,9 +317,9 @@ public class DefaultArchivaConfiguration { Policy policy = findPolicy( policyId ); // Does option exist? - if ( !policy.getOptions().contains( setting ) ) + if ( !policy.getOptions( ).contains( setting ) ) { - setting = policy.getDefaultOption(); + setting = policy.getDefaultOption( ); } connector.addPolicy( policyId, setting ); } @@ -337,12 +338,12 @@ public class DefaultArchivaConfiguration // Normalize the order fields in the proxy connectors. Map> proxyConnectorMap = - config.getProxyConnectorAsMap(); + config.getProxyConnectorAsMap( ); - for ( List connectors : proxyConnectorMap.values() ) + for ( List connectors : proxyConnectorMap.values( ) ) { // Sort connectors by order field. - Collections.sort( connectors, ProxyConnectorConfigurationOrderComparator.getInstance() ); + Collections.sort( connectors, ProxyConnectorConfigurationOrderComparator.getInstance( ) ); // Normalize the order field values. int order = 1; @@ -404,7 +405,7 @@ public class DefaultArchivaConfiguration return ( prePolicies.containsKey( policyId ) || postPolicies.containsKey( policyId ) ); } - private Registry readDefaultConfiguration() + private Registry readDefaultConfiguration( ) { // if it contains some old configuration, remove it (Archiva 0.9) registry.removeSubset( KEY ); @@ -433,23 +434,23 @@ public class DefaultArchivaConfiguration section = baseSection; if ( section == null ) { - section = createDefaultConfigurationFile(); + section = createDefaultConfigurationFile( ); } } else if ( baseSection != null ) { - Collection keys = baseSection.getKeys(); + Collection keys = baseSection.getKeys( ); boolean foundList = false; - for ( Iterator i = keys.iterator(); i.hasNext() && !foundList; ) + for ( Iterator i = keys.iterator( ); i.hasNext( ) && !foundList; ) { - String key = i.next(); + String key = i.next( ); // a little aggressive with the repositoryScanning and databaseScanning - should be no need to split // that configuration - if ( key.startsWith( "repositories" ) || key.startsWith( "proxyConnectors" ) - || key.startsWith( "networkProxies" ) || key.startsWith( "repositoryScanning" ) - || key.startsWith( "databaseScanning" ) || key.startsWith( "remoteRepositories" ) - || key.startsWith( "managedRepositories" ) || key.startsWith( "repositoryGroups" ) ) + if ( key.startsWith( "repositories" ) || key.startsWith( "proxyConnectors" ) || key.startsWith( + "networkProxies" ) || key.startsWith( "repositoryScanning" ) || key.startsWith( + "remoteRepositories" ) || key.startsWith( "managedRepositories" ) || key.startsWith( + "repositoryGroups" ) ) { foundList = true; } @@ -468,45 +469,45 @@ public class DefaultArchivaConfiguration escapeCronExpressions( configuration ); // [MRM-661] Due to a bug in the modello registry writer, we need to take these out by hand. They'll be put back by the writer. - if ( configuration.getManagedRepositories().isEmpty() && section != null ) + if ( configuration.getManagedRepositories( ).isEmpty( ) && section != null ) { section.removeSubset( "managedRepositories" ); } - if ( configuration.getRemoteRepositories().isEmpty() && section != null ) + if ( configuration.getRemoteRepositories( ).isEmpty( ) && section != null ) { section.removeSubset( "remoteRepositories" ); } - if ( configuration.getProxyConnectors().isEmpty() && section != null ) + if ( configuration.getProxyConnectors( ).isEmpty( ) && section != null ) { section.removeSubset( "proxyConnectors" ); } - if ( configuration.getNetworkProxies().isEmpty() && section != null ) + if ( configuration.getNetworkProxies( ).isEmpty( ) && section != null ) { section.removeSubset( "networkProxies" ); } - if ( configuration.getLegacyArtifactPaths().isEmpty() && section != null ) + if ( configuration.getLegacyArtifactPaths( ).isEmpty( ) && section != null ) { section.removeSubset( "legacyArtifactPaths" ); } - if ( configuration.getRepositoryGroups().isEmpty() && section != null ) + if ( configuration.getRepositoryGroups( ).isEmpty( ) && section != null ) { section.removeSubset( "repositoryGroups" ); } - if ( configuration.getRepositoryScanning() != null ) + if ( configuration.getRepositoryScanning( ) != null ) { - if ( configuration.getRepositoryScanning().getKnownContentConsumers().isEmpty() && section != null ) + if ( configuration.getRepositoryScanning( ).getKnownContentConsumers( ).isEmpty( ) && section != null ) { section.removeSubset( "repositoryScanning.knownContentConsumers" ); } - if ( configuration.getRepositoryScanning().getInvalidContentConsumers().isEmpty() && section != null ) + if ( configuration.getRepositoryScanning( ).getInvalidContentConsumers( ).isEmpty( ) && section != null ) { section.removeSubset( "repositoryScanning.invalidContentConsumers" ); } } - new ConfigurationRegistryWriter().write( configuration, section ); - section.save(); + new ConfigurationRegistryWriter( ).write( configuration, section ); + section.save( ); this.configuration = unescapeExpressions( configuration ); @@ -515,15 +516,15 @@ public class DefaultArchivaConfiguration private void escapeCronExpressions( Configuration configuration ) { - for ( ManagedRepositoryConfiguration c : (List) configuration.getManagedRepositories() ) + for ( ManagedRepositoryConfiguration c : (List) configuration.getManagedRepositories( ) ) { - c.setRefreshCronExpression( escapeCronExpression( c.getRefreshCronExpression() ) ); + c.setRefreshCronExpression( escapeCronExpression( c.getRefreshCronExpression( ) ) ); } } - private Registry createDefaultConfigurationFile() + private Registry createDefaultConfigurationFile( ) throws RegistryException { // TODO: may not be needed under commons-configuration 1.4 - check @@ -551,7 +552,7 @@ public class DefaultArchivaConfiguration ( (CommonsConfigurationRegistry) registry ).setProperties( contents ); - registry.initialize(); + registry.initialize( ); for ( RegistryListener regListener : registryListeners ) { @@ -561,7 +562,7 @@ public class DefaultArchivaConfiguration triggerEvent( ConfigurationEvent.SAVED ); Registry section = registry.getSection( KEY + ".user" ); - return section == null ? new CommonsConfigurationRegistry( new BaseConfiguration() ) : section; + return section == null ? new CommonsConfigurationRegistry( new BaseConfiguration( ) ) : section; } /** @@ -581,10 +582,10 @@ public class DefaultArchivaConfiguration try { // Check parent directory (if it is declared) - if ( file.getParentFile() != null ) + if ( file.getParentFile( ) != null ) { // Check that directory exists - if ( ( file.getParentFile().exists() == false ) || ( file.getParentFile().isDirectory() == false ) ) + if ( ( file.getParentFile( ).exists( ) == false ) || ( file.getParentFile( ).isDirectory( ) == false ) ) { // Directory to file must exist for file to be created return false; @@ -596,7 +597,7 @@ public class DefaultArchivaConfiguration } catch ( IOException e ) { - log.error( "Unable to create " + filetype + " file: " + e.getMessage(), e ); + log.error( "Unable to create " + filetype + " file: " + e.getMessage( ), e ); return false; } } @@ -653,7 +654,7 @@ public class DefaultArchivaConfiguration } @PostConstruct - public void initialize() + public void initialize( ) { this.postPolicies = componentContainer.buildMapWithRole( PostDownloadPolicy.class ); @@ -661,8 +662,8 @@ public class DefaultArchivaConfiguration // Resolve expressions in the userConfigFilename and altConfigFilename try { - ExpressionEvaluator expressionEvaluator = new DefaultExpressionEvaluator(); - expressionEvaluator.addExpressionSource( new SystemPropertyExpressionSource() ); + ExpressionEvaluator expressionEvaluator = new DefaultExpressionEvaluator( ); + expressionEvaluator.addExpressionSource( new SystemPropertyExpressionSource( ) ); String userConfigFileNameSysProps = System.getProperty( "archiva.user.configFileName" ); if ( StringUtils.isNotBlank( userConfigFileNameSysProps ) ) { @@ -673,7 +674,16 @@ public class DefaultArchivaConfiguration userConfigFilename = expressionEvaluator.expand( userConfigFilename ); } altConfigFilename = expressionEvaluator.expand( altConfigFilename ); - loadConfiguration(); + loadConfiguration( ); + handleUpgradeConfiguration( ); + } + catch ( IndeterminateConfigurationException e ) + { + throw new RuntimeException( "failed during upgrade from previous version" + e.getMessage( ), e ); + } + catch ( RegistryException e ) + { + throw new RuntimeException( "failed during upgrade from previous version" + e.getMessage( ), e ); } catch ( EvaluatorException e ) { @@ -683,18 +693,60 @@ public class DefaultArchivaConfiguration registry.addChangeListener( this ); } - public void reload() + /** + * upgrade from 1.3 + */ + private void handleUpgradeConfiguration( ) + throws RegistryException, IndeterminateConfigurationException + { + + // remove database consumers + List dbConsumers = Arrays.asList( "update-db-artifact", "update-db-repository-metadata" ); + List knowContentConsumers = new ArrayList( ); + for ( String knowContentConsumer : configuration.getRepositoryScanning( ).getKnownContentConsumers( ) ) + { + if ( !dbConsumers.contains( knowContentConsumer ) ) + { + knowContentConsumers.add( knowContentConsumer ); + } + } + + configuration.getRepositoryScanning( ).setKnownContentConsumers( knowContentConsumers ); + save( configuration ); + + // ensure create-archiva-metadata is here + if ( !configuration.getRepositoryScanning( ).getKnownContentConsumers( ).contains( "create-archiva-metadata" ) ) + { + knowContentConsumers = + new ArrayList( configuration.getRepositoryScanning( ).getKnownContentConsumers( ) ); + knowContentConsumers.add( "create-archiva-metadata" ); + configuration.getRepositoryScanning( ).setKnownContentConsumers( knowContentConsumers ); + save( configuration ); + } + + // ensure duplicate-artifacts is here + if ( !configuration.getRepositoryScanning( ).getKnownContentConsumers( ).contains( "duplicate-artifacts" ) ) + { + knowContentConsumers = + new ArrayList( configuration.getRepositoryScanning( ).getKnownContentConsumers( ) ); + knowContentConsumers.add( "duplicate-artifacts" ); + configuration.getRepositoryScanning( ).setKnownContentConsumers( knowContentConsumers ); + save( configuration ); + } + } + + public void reload( ) { this.configuration = null; try { - this.registry.initialize(); + this.registry.initialize( ); } catch ( RegistryException e ) { - throw new ConfigurationRuntimeException( e.getMessage(), e ); + throw new ConfigurationRuntimeException( e.getMessage( ), e ); } - this.initialize(); + this.initialize( ); } public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue ) @@ -729,11 +781,11 @@ public class DefaultArchivaConfiguration private Configuration unescapeExpressions( Configuration config ) { // TODO: for commons-configuration 1.3 only - for ( Iterator i = config.getManagedRepositories().iterator(); i.hasNext(); ) + for ( Iterator i = config.getManagedRepositories( ).iterator( ); i.hasNext( ); ) { - ManagedRepositoryConfiguration c = i.next(); - c.setLocation( removeExpressions( c.getLocation() ) ); - c.setRefreshCronExpression( unescapeCronExpression( c.getRefreshCronExpression() ) ); + ManagedRepositoryConfiguration c = i.next( ); + c.setLocation( removeExpressions( c.getLocation( ) ) ); + c.setRefreshCronExpression( unescapeCronExpression( c.getRefreshCronExpression( ) ) ); } return config; @@ -743,37 +795,37 @@ public class DefaultArchivaConfiguration { // additional check for [MRM-789], ensure that the location of the default repositories // are not installed in the server installation - for ( ManagedRepositoryConfiguration repo : (List) config.getManagedRepositories() ) + for ( ManagedRepositoryConfiguration repo : (List) config.getManagedRepositories( ) ) { - String repoPath = repo.getLocation(); + String repoPath = repo.getLocation( ); File repoLocation = new File( repoPath ); - if ( repoLocation.exists() && repoLocation.isDirectory() && !repoPath.endsWith( - "data/repositories/" + repo.getId() ) ) + if ( repoLocation.exists( ) && repoLocation.isDirectory( ) && !repoPath.endsWith( + "data/repositories/" + repo.getId( ) ) ) { - repo.setLocation( repoPath + "/data/repositories/" + repo.getId() ); + repo.setLocation( repoPath + "/data/repositories/" + repo.getId( ) ); } } return config; } - public String getUserConfigFilename() + public String getUserConfigFilename( ) { return userConfigFilename; } - public String getAltConfigFilename() + public String getAltConfigFilename( ) { return altConfigFilename; } - public boolean isDefaulted() + public boolean isDefaulted( ) { return this.isConfigurationDefaulted; } - public Registry getRegistry() + public Registry getRegistry( ) { return registry; } diff --git a/archiva-modules/archiva-base/archiva-configuration/src/test/conf/archiva-1.3.xml b/archiva-modules/archiva-base/archiva-configuration/src/test/conf/archiva-1.3.xml new file mode 100644 index 000000000..5d2a85d63 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-configuration/src/test/conf/archiva-1.3.xml @@ -0,0 +1,154 @@ + + +2 + + + +artifacts + +**/*.pom +**/*.jar +**/*.ear +**/*.war +**/*.car +**/*.sar +**/*.mar +**/*.rar +**/*.dtd +**/*.tld +**/*.tar.gz +**/*.tar.bz2 +**/*.zip + + + +indexable-content + +**/*.txt +**/*.TXT +**/*.block +**/*.config +**/*.pom +**/*.xml +**/*.xsd +**/*.dtd +**/*.tld + + + +auto-remove + +**/*.bak +**/*~ +**/*- + + + +ignored + +**/.htaccess +**/KEYS +**/*.rb +**/*.sh +**/.svn/** +**/.DAV/** + + + + +update-db-artifact +create-missing-checksums +update-db-repository-metadata +validate-checksum +validate-signature +index-content +auto-remove +auto-rename +metadata-updater + + +update-db-bad-content + + + +0 0 * * * ? + +update-db-project + + +not-present-remove-db-artifact +not-present-remove-db-project +not-present-remove-indexed + + + + +${appserver.base}/data/repositories/internal +true +30 +internal +Archiva Managed Internal Repository + + +${appserver.base}/data/repositories/snapshots +false +true +0 0\,30 * * * ? +30 +snapshots +Archiva Managed Snapshot Repository + + + + +http://repo1.maven.org/maven2 +central +Central Repository + + +http://download.java.net/maven/2/ +maven2-repository.dev.java.net +Java.net Repository for Maven 2 + + + + +1 +internal +central + + +**/* + + +once +fix +never +yes + + + +2 +internal +maven2-repository.dev.java.net + + +javax/** +org/jvnet/** +com/sun/** + + +once +fix +never +yes + + + + + +jaxen/jars/jaxen-1.0-FCS-full.jar +jaxen:jaxen:1.0-FCS:full:jar + + + diff --git a/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java b/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java index 52d0d252e..a46a1a5b6 100644 --- a/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java +++ b/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java @@ -29,6 +29,8 @@ import org.custommonkey.xmlunit.XMLAssert; import org.easymock.MockControl; import org.junit.Test; import org.junit.runner.RunWith; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -46,12 +48,14 @@ public class ArchivaConfigurationTest extends TestCase { + private Logger log = LoggerFactory.getLogger( getClass( ) ); + @Inject private ComponentContainer componentContainer; public static File getTestFile( String path ) { - return new File( FileUtil.getBasedir(), path ); + return new File( FileUtil.getBasedir( ), path ); } protected T lookup( Class clazz, String hint ) @@ -65,64 +69,64 @@ public class ArchivaConfigurationTest } @Test - public void testGetConfigurationFromRegistryWithASingleNamedConfigurationResource() + public void testGetConfigurationFromRegistryWithASingleNamedConfigurationResource( ) throws Exception { ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-configuration" ); - Configuration configuration = archivaConfiguration.getConfiguration(); + Configuration configuration = archivaConfiguration.getConfiguration( ); assertConfiguration( configuration, 2, 2, 2 ); - assertEquals( "check network proxies", 1, configuration.getNetworkProxies().size() ); + assertEquals( "check network proxies", 1, configuration.getNetworkProxies( ).size( ) ); - ManagedRepositoryConfiguration repository = configuration.getManagedRepositories().get( 0 ); + ManagedRepositoryConfiguration repository = configuration.getManagedRepositories( ).get( 0 ); assertEquals( "check managed repositories", "${appserver.base}/repositories/internal", - repository.getLocation() ); - assertEquals( "check managed repositories", "Archiva Managed Internal Repository", repository.getName() ); - assertEquals( "check managed repositories", "internal", repository.getId() ); - assertEquals( "check managed repositories", "default", repository.getLayout() ); - assertTrue( "check managed repositories", repository.isScanned() ); + repository.getLocation( ) ); + assertEquals( "check managed repositories", "Archiva Managed Internal Repository", repository.getName( ) ); + assertEquals( "check managed repositories", "internal", repository.getId( ) ); + assertEquals( "check managed repositories", "default", repository.getLayout( ) ); + assertTrue( "check managed repositories", repository.isScanned( ) ); } @Test - public void testGetConfigurationFromDefaults() + public void testGetConfigurationFromDefaults( ) throws Exception { ArchivaConfiguration archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class, "test-defaults" ); - Configuration configuration = archivaConfiguration.getConfiguration(); + Configuration configuration = archivaConfiguration.getConfiguration( ); assertConfiguration( configuration, 2, 1, 1 ); - assertEquals( "check network proxies", 0, configuration.getNetworkProxies().size() ); + assertEquals( "check network proxies", 0, configuration.getNetworkProxies( ).size( ) ); ManagedRepositoryConfiguration repository = - (ManagedRepositoryConfiguration) configuration.getManagedRepositories().get( 0 ); + (ManagedRepositoryConfiguration) configuration.getManagedRepositories( ).get( 0 ); assertEquals( "check managed repositories", "${appserver.base}/data/repositories/internal", - repository.getLocation() ); - assertEquals( "check managed repositories", "Archiva Managed Internal Repository", repository.getName() ); - assertEquals( "check managed repositories", "internal", repository.getId() ); - assertEquals( "check managed repositories", "default", repository.getLayout() ); - assertTrue( "check managed repositories", repository.isScanned() ); + repository.getLocation( ) ); + assertEquals( "check managed repositories", "Archiva Managed Internal Repository", repository.getName( ) ); + assertEquals( "check managed repositories", "internal", repository.getId( ) ); + assertEquals( "check managed repositories", "default", repository.getLayout( ) ); + assertTrue( "check managed repositories", repository.isScanned( ) ); } // test for [MRM-789] @Test - public void testGetConfigurationFromDefaultsWithDefaultRepoLocationAlreadyExisting() + public void testGetConfigurationFromDefaultsWithDefaultRepoLocationAlreadyExisting( ) throws Exception { - File repo = new File( FileUtil.getBasedir(), "/target/test-classes/existing_snapshots" ); - repo.mkdirs(); + File repo = new File( FileUtil.getBasedir( ), "/target/test-classes/existing_snapshots" ); + repo.mkdirs( ); - repo = new File( FileUtil.getBasedir(), "/target/test-classes/existing_internal" ); - repo.mkdirs(); + repo = new File( FileUtil.getBasedir( ), "/target/test-classes/existing_internal" ); + repo.mkdirs( ); String existingTestDefaultArchivaConfigFile = FileUtils.readFileToString( getTestFile( "target/test-classes/org/apache/archiva/configuration/test-default-archiva.xml" ) ); existingTestDefaultArchivaConfigFile = - StringUtils.replace( existingTestDefaultArchivaConfigFile, "${appserver.base}", FileUtil.getBasedir() ); + StringUtils.replace( existingTestDefaultArchivaConfigFile, "${appserver.base}", FileUtil.getBasedir( ) ); - File generatedTestDefaultArchivaConfigFile = new File( FileUtil.getBasedir(), + File generatedTestDefaultArchivaConfigFile = new File( FileUtil.getBasedir( ), "target/test-classes/org/apache/archiva/configuration/default-archiva.xml" ); FileUtils.writeStringToFile( generatedTestDefaultArchivaConfigFile, existingTestDefaultArchivaConfigFile, @@ -131,15 +135,15 @@ public class ArchivaConfigurationTest ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-defaults-default-repo-location-exists" ); - Configuration configuration = archivaConfiguration.getConfiguration(); + Configuration configuration = archivaConfiguration.getConfiguration( ); assertConfiguration( configuration, 2, 1, 1 ); ManagedRepositoryConfiguration repository = - (ManagedRepositoryConfiguration) configuration.getManagedRepositories().get( 0 ); - assertTrue( "check managed repositories", repository.getLocation().endsWith( "data/repositories/internal" ) ); + (ManagedRepositoryConfiguration) configuration.getManagedRepositories( ).get( 0 ); + assertTrue( "check managed repositories", repository.getLocation( ).endsWith( "data/repositories/internal" ) ); - generatedTestDefaultArchivaConfigFile.delete(); - assertFalse( generatedTestDefaultArchivaConfigFile.exists() ); + generatedTestDefaultArchivaConfigFile.delete( ); + assertFalse( generatedTestDefaultArchivaConfigFile.exists( ) ); } private void assertConfiguration( Configuration configuration ) @@ -157,59 +161,59 @@ public class ArchivaConfigurationTest { FileTypes filetypes = lookup( FileTypes.class ); - assertEquals( "check managed repositories: " + configuration.getManagedRepositories(), managedExpected, - configuration.getManagedRepositories().size() ); - assertEquals( "check remote repositories: " + configuration.getRemoteRepositories(), remoteExpected, - configuration.getRemoteRepositories().size() ); - assertEquals( "check proxy connectors:" + configuration.getProxyConnectors(), proxyConnectorExpected, - configuration.getProxyConnectors().size() ); + assertEquals( "check managed repositories: " + configuration.getManagedRepositories( ), managedExpected, + configuration.getManagedRepositories( ).size( ) ); + assertEquals( "check remote repositories: " + configuration.getRemoteRepositories( ), remoteExpected, + configuration.getRemoteRepositories( ).size( ) ); + assertEquals( "check proxy connectors:" + configuration.getProxyConnectors( ), proxyConnectorExpected, + configuration.getProxyConnectors( ).size( ) ); - RepositoryScanningConfiguration repoScanning = configuration.getRepositoryScanning(); + RepositoryScanningConfiguration repoScanning = configuration.getRepositoryScanning( ); assertNotNull( "check repository scanning", repoScanning ); - assertEquals( "check file types", 4, repoScanning.getFileTypes().size() ); - assertEquals( "check known consumers", 9, repoScanning.getKnownContentConsumers().size() ); - assertEquals( "check invalid consumers", 1, repoScanning.getInvalidContentConsumers().size() ); + assertEquals( "check file types", 4, repoScanning.getFileTypes( ).size( ) ); + assertEquals( "check known consumers", 9, repoScanning.getKnownContentConsumers( ).size( ) ); + assertEquals( "check invalid consumers", 1, repoScanning.getInvalidContentConsumers( ).size( ) ); List patterns = filetypes.getFileTypePatterns( "artifacts" ); assertNotNull( "check 'artifacts' file type", patterns ); - assertEquals( "check 'artifacts' patterns", 13, patterns.size() ); + assertEquals( "check 'artifacts' patterns", 13, patterns.size( ) ); - WebappConfiguration webapp = configuration.getWebapp(); + WebappConfiguration webapp = configuration.getWebapp( ); assertNotNull( "check webapp", webapp ); - UserInterfaceOptions ui = webapp.getUi(); + UserInterfaceOptions ui = webapp.getUi( ); assertNotNull( "check webapp ui", ui ); - assertTrue( "check showFindArtifacts", ui.isShowFindArtifacts() ); - assertTrue( "check appletFindEnabled", ui.isAppletFindEnabled() ); + assertTrue( "check showFindArtifacts", ui.isShowFindArtifacts( ) ); + assertTrue( "check appletFindEnabled", ui.isAppletFindEnabled( ) ); } @Test - public void testGetConfigurationFromRegistryWithTwoConfigurationResources() + public void testGetConfigurationFromRegistryWithTwoConfigurationResources( ) throws Exception { ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-configuration-both" ); - Configuration configuration = archivaConfiguration.getConfiguration(); + Configuration configuration = archivaConfiguration.getConfiguration( ); // from base - assertEquals( "check repositories", 2, configuration.getManagedRepositories().size() ); - assertEquals( "check repositories", 2, configuration.getRemoteRepositories().size() ); + assertEquals( "check repositories", 2, configuration.getManagedRepositories( ).size( ) ); + assertEquals( "check repositories", 2, configuration.getRemoteRepositories( ).size( ) ); // from user - assertEquals( "check proxy connectors", 2, configuration.getProxyConnectors().size() ); + assertEquals( "check proxy connectors", 2, configuration.getProxyConnectors( ).size( ) ); - WebappConfiguration webapp = configuration.getWebapp(); + WebappConfiguration webapp = configuration.getWebapp( ); assertNotNull( "check webapp", webapp ); - UserInterfaceOptions ui = webapp.getUi(); + UserInterfaceOptions ui = webapp.getUi( ); assertNotNull( "check webapp ui", ui ); // from base - assertFalse( "check showFindArtifacts", ui.isShowFindArtifacts() ); + assertFalse( "check showFindArtifacts", ui.isShowFindArtifacts( ) ); // from user - assertFalse( "check appletFindEnabled", ui.isAppletFindEnabled() ); + assertFalse( "check appletFindEnabled", ui.isAppletFindEnabled( ) ); } @Test - public void testGetConfigurationSystemOverride() + public void testGetConfigurationSystemOverride( ) throws Exception { @@ -217,27 +221,27 @@ public class ArchivaConfigurationTest ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-configuration" ); - archivaConfiguration.reload(); + archivaConfiguration.reload( ); try { - Configuration configuration = archivaConfiguration.getConfiguration(); + Configuration configuration = archivaConfiguration.getConfiguration( ); - assertFalse( "check boolean", configuration.getWebapp().getUi().isAppletFindEnabled() ); + assertFalse( "check boolean", configuration.getWebapp( ).getUi( ).isAppletFindEnabled( ) ); } finally { - System.getProperties().remove( "org.apache.archiva.webapp.ui.appletFindEnabled" ); + System.getProperties( ).remove( "org.apache.archiva.webapp.ui.appletFindEnabled" ); } } @Test - public void testStoreConfiguration() + public void testStoreConfiguration( ) throws Exception { File file = getTestFile( "target/test/test-file.xml" ); - file.delete(); - assertFalse( file.exists() ); + file.delete( ); + assertFalse( file.exists( ) ); // TODO: remove with commons-configuration 1.4 //file.getParentFile().mkdirs(); @@ -246,286 +250,286 @@ public class ArchivaConfigurationTest DefaultArchivaConfiguration archivaConfiguration = (DefaultArchivaConfiguration) lookup( ArchivaConfiguration.class, "test-save" ); - archivaConfiguration.reload(); + archivaConfiguration.reload( ); - Configuration configuration = new Configuration(); + Configuration configuration = new Configuration( ); configuration.setVersion( "1" ); - configuration.setWebapp( new WebappConfiguration() ); - configuration.getWebapp().setUi( new UserInterfaceOptions() ); - configuration.getWebapp().getUi().setAppletFindEnabled( false ); + configuration.setWebapp( new WebappConfiguration( ) ); + configuration.getWebapp( ).setUi( new UserInterfaceOptions( ) ); + configuration.getWebapp( ).getUi( ).setAppletFindEnabled( false ); // add a change listener - MockControl control = createConfigurationListenerMockControl(); - ConfigurationListener listener = (ConfigurationListener) control.getMock(); + MockControl control = createConfigurationListenerMockControl( ); + ConfigurationListener listener = (ConfigurationListener) control.getMock( ); archivaConfiguration.addListener( listener ); listener.configurationEvent( new ConfigurationEvent( ConfigurationEvent.SAVED ) ); - control.setVoidCallable(); + control.setVoidCallable( ); - control.replay(); + control.replay( ); archivaConfiguration.save( configuration ); - control.verify(); + control.verify( ); - assertTrue( "Check file exists", file.exists() ); + assertTrue( "Check file exists", file.exists( ) ); // check it - configuration = archivaConfiguration.getConfiguration(); - assertFalse( "check value", configuration.getWebapp().getUi().isAppletFindEnabled() ); + configuration = archivaConfiguration.getConfiguration( ); + assertFalse( "check value", configuration.getWebapp( ).getUi( ).isAppletFindEnabled( ) ); // read it back archivaConfiguration = (DefaultArchivaConfiguration) lookup( ArchivaConfiguration.class, "test-read-saved" ); - archivaConfiguration.reload(); - configuration = archivaConfiguration.getConfiguration(); - assertFalse( "check value", configuration.getWebapp().getUi().isAppletFindEnabled() ); + archivaConfiguration.reload( ); + configuration = archivaConfiguration.getConfiguration( ); + assertFalse( "check value", configuration.getWebapp( ).getUi( ).isAppletFindEnabled( ) ); } - private static MockControl createConfigurationListenerMockControl() + private static MockControl createConfigurationListenerMockControl( ) { return MockControl.createControl( ConfigurationListener.class ); } @Test - public void testStoreConfigurationUser() + public void testStoreConfigurationUser( ) throws Exception { File baseFile = getTestFile( "target/test/test-file.xml" ); - baseFile.delete(); - assertFalse( baseFile.exists() ); + baseFile.delete( ); + assertFalse( baseFile.exists( ) ); File userFile = getTestFile( "target/test/test-file-user.xml" ); - userFile.delete(); - assertFalse( userFile.exists() ); + userFile.delete( ); + assertFalse( userFile.exists( ) ); - userFile.getParentFile().mkdirs(); + userFile.getParentFile( ).mkdirs( ); FileUtils.writeStringToFile( userFile, "", null ); ArchivaConfiguration archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class, "test-save-user" ); - Configuration configuration = new Configuration(); - configuration.setWebapp( new WebappConfiguration() ); - configuration.getWebapp().setUi( new UserInterfaceOptions() ); - configuration.getWebapp().getUi().setAppletFindEnabled( false ); + Configuration configuration = new Configuration( ); + configuration.setWebapp( new WebappConfiguration( ) ); + configuration.getWebapp( ).setUi( new UserInterfaceOptions( ) ); + configuration.getWebapp( ).getUi( ).setAppletFindEnabled( false ); archivaConfiguration.save( configuration ); - assertTrue( "Check file exists", userFile.exists() ); - assertFalse( "Check file not created", baseFile.exists() ); + assertTrue( "Check file exists", userFile.exists( ) ); + assertFalse( "Check file not created", baseFile.exists( ) ); // check it - configuration = archivaConfiguration.getConfiguration(); - assertFalse( "check value", configuration.getWebapp().getUi().isAppletFindEnabled() ); + configuration = archivaConfiguration.getConfiguration( ); + assertFalse( "check value", configuration.getWebapp( ).getUi( ).isAppletFindEnabled( ) ); } @Test - public void testStoreConfigurationLoadedFromDefaults() + public void testStoreConfigurationLoadedFromDefaults( ) throws Exception { File baseFile = getTestFile( "target/test/test-file.xml" ); - baseFile.delete(); - assertFalse( baseFile.exists() ); + baseFile.delete( ); + assertFalse( baseFile.exists( ) ); File userFile = getTestFile( "target/test/test-file-user.xml" ); - userFile.delete(); - assertFalse( userFile.exists() ); + userFile.delete( ); + assertFalse( userFile.exists( ) ); ArchivaConfiguration archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class, "test-save-user-defaults" ); - archivaConfiguration.reload(); + archivaConfiguration.reload( ); - Configuration configuration = new Configuration(); - configuration.setWebapp( new WebappConfiguration() ); - configuration.getWebapp().setUi( new UserInterfaceOptions() ); - configuration.getWebapp().getUi().setAppletFindEnabled( false ); + Configuration configuration = new Configuration( ); + configuration.setWebapp( new WebappConfiguration( ) ); + configuration.getWebapp( ).setUi( new UserInterfaceOptions( ) ); + configuration.getWebapp( ).getUi( ).setAppletFindEnabled( false ); // add a change listener - MockControl control = createConfigurationListenerMockControl(); - ConfigurationListener listener = (ConfigurationListener) control.getMock(); + MockControl control = createConfigurationListenerMockControl( ); + ConfigurationListener listener = (ConfigurationListener) control.getMock( ); archivaConfiguration.addListener( listener ); listener.configurationEvent( new ConfigurationEvent( ConfigurationEvent.SAVED ) ); control.setVoidCallable( 1 ); - control.replay(); + control.replay( ); archivaConfiguration.save( configuration ); - control.verify(); + control.verify( ); - assertTrue( "Check file exists", userFile.exists() ); - assertFalse( "Check file not created", baseFile.exists() ); + assertTrue( "Check file exists", userFile.exists( ) ); + assertFalse( "Check file not created", baseFile.exists( ) ); // check it - configuration = archivaConfiguration.getConfiguration(); - assertFalse( "check value", configuration.getWebapp().getUi().isAppletFindEnabled() ); + configuration = archivaConfiguration.getConfiguration( ); + assertFalse( "check value", configuration.getWebapp( ).getUi( ).isAppletFindEnabled( ) ); } @Test - public void testDefaultUserConfigFilename() + public void testDefaultUserConfigFilename( ) throws Exception { DefaultArchivaConfiguration archivaConfiguration = (DefaultArchivaConfiguration) lookup( ArchivaConfiguration.class, "default" ); - archivaConfiguration.reload(); + archivaConfiguration.reload( ); assertEquals( System.getProperty( "user.home" ) + "/.m2/archiva.xml", - archivaConfiguration.getUserConfigFilename() ); + archivaConfiguration.getUserConfigFilename( ) ); assertEquals( System.getProperty( "appserver.base", "${appserver.base}" ) + "/conf/archiva.xml", - archivaConfiguration.getAltConfigFilename() ); + archivaConfiguration.getAltConfigFilename( ) ); } @Test - public void testStoreConfigurationFallback() + public void testStoreConfigurationFallback( ) throws Exception { File baseFile = getTestFile( "target/test/test-file.xml" ); - baseFile.delete(); - assertFalse( baseFile.exists() ); + baseFile.delete( ); + assertFalse( baseFile.exists( ) ); File userFile = getTestFile( "target/test/test-file-user.xml" ); - userFile.delete(); - assertFalse( userFile.exists() ); + userFile.delete( ); + assertFalse( userFile.exists( ) ); - baseFile.getParentFile().mkdirs(); + baseFile.getParentFile( ).mkdirs( ); FileUtils.writeStringToFile( baseFile, "", null ); ArchivaConfiguration archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class, "test-save-user-fallback" ); - archivaConfiguration.reload(); + archivaConfiguration.reload( ); - Configuration configuration = new Configuration(); - configuration.setWebapp( new WebappConfiguration() ); - configuration.getWebapp().setUi( new UserInterfaceOptions() ); - configuration.getWebapp().getUi().setAppletFindEnabled( false ); + Configuration configuration = new Configuration( ); + configuration.setWebapp( new WebappConfiguration( ) ); + configuration.getWebapp( ).setUi( new UserInterfaceOptions( ) ); + configuration.getWebapp( ).getUi( ).setAppletFindEnabled( false ); archivaConfiguration.save( configuration ); - assertTrue( "Check file exists", baseFile.exists() ); - assertFalse( "Check file not created", userFile.exists() ); + assertTrue( "Check file exists", baseFile.exists( ) ); + assertFalse( "Check file not created", userFile.exists( ) ); // check it - configuration = archivaConfiguration.getConfiguration(); - assertFalse( "check value", configuration.getWebapp().getUi().isAppletFindEnabled() ); + configuration = archivaConfiguration.getConfiguration( ); + assertFalse( "check value", configuration.getWebapp( ).getUi( ).isAppletFindEnabled( ) ); } @Test - public void testStoreConfigurationFailsWhenReadFromBothLocationsNoLists() + public void testStoreConfigurationFailsWhenReadFromBothLocationsNoLists( ) throws Exception { File baseFile = getTestFile( "target/test/test-file.xml" ); - baseFile.delete(); - assertFalse( baseFile.exists() ); + baseFile.delete( ); + assertFalse( baseFile.exists( ) ); File userFile = getTestFile( "target/test/test-file-user.xml" ); - userFile.delete(); - assertFalse( userFile.exists() ); + userFile.delete( ); + assertFalse( userFile.exists( ) ); - baseFile.getParentFile().mkdirs(); + baseFile.getParentFile( ).mkdirs( ); FileUtils.writeStringToFile( baseFile, "", null ); - userFile.getParentFile().mkdirs(); + userFile.getParentFile( ).mkdirs( ); FileUtils.writeStringToFile( userFile, "", null ); ArchivaConfiguration archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class, "test-save-user" ); - archivaConfiguration.reload(); + archivaConfiguration.reload( ); - Configuration configuration = archivaConfiguration.getConfiguration(); - assertTrue( "check value", configuration.getWebapp().getUi().isAppletFindEnabled() ); + Configuration configuration = archivaConfiguration.getConfiguration( ); + assertTrue( "check value", configuration.getWebapp( ).getUi( ).isAppletFindEnabled( ) ); - configuration.getWebapp().getUi().setAppletFindEnabled( false ); + configuration.getWebapp( ).getUi( ).setAppletFindEnabled( false ); archivaConfiguration.save( configuration ); - assertTrue( "Check file exists", baseFile.exists() ); + assertTrue( "Check file exists", baseFile.exists( ) ); assertEquals( "Check base file is unchanged", "", FileUtils.readFileToString( baseFile, null ) ); - assertTrue( "Check file exists", userFile.exists() ); + assertTrue( "Check file exists", userFile.exists( ) ); assertFalse( "Check base file is changed", "".equals( FileUtils.readFileToString( userFile, null ) ) ); // check it - configuration = archivaConfiguration.getConfiguration(); - assertFalse( "check value", configuration.getWebapp().getUi().isAppletFindEnabled() ); + configuration = archivaConfiguration.getConfiguration( ); + assertFalse( "check value", configuration.getWebapp( ).getUi( ).isAppletFindEnabled( ) ); } @Test - public void testStoreConfigurationFailsWhenReadFromBothLocationsUserHasLists() + public void testStoreConfigurationFailsWhenReadFromBothLocationsUserHasLists( ) throws Exception { File baseFile = getTestFile( "target/test/test-file.xml" ); - baseFile.delete(); - assertFalse( baseFile.exists() ); + baseFile.delete( ); + assertFalse( baseFile.exists( ) ); File userFile = getTestFile( "target/test/test-file-user.xml" ); - userFile.delete(); - assertFalse( userFile.exists() ); + userFile.delete( ); + assertFalse( userFile.exists( ) ); - userFile.getParentFile().mkdirs(); + userFile.getParentFile( ).mkdirs( ); FileUtils.copyFile( getTestFile( "src/test/conf/conf-user.xml" ), userFile ); - baseFile.getParentFile().mkdirs(); + baseFile.getParentFile( ).mkdirs( ); FileUtils.writeStringToFile( baseFile, "", null ); ArchivaConfiguration archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class, "test-save-user" ); - archivaConfiguration.reload(); + archivaConfiguration.reload( ); - Configuration configuration = archivaConfiguration.getConfiguration(); - assertTrue( "check value", configuration.getWebapp().getUi().isShowFindArtifacts() ); + Configuration configuration = archivaConfiguration.getConfiguration( ); + assertTrue( "check value", configuration.getWebapp( ).getUi( ).isShowFindArtifacts( ) ); - configuration.getWebapp().getUi().setShowFindArtifacts( false ); + configuration.getWebapp( ).getUi( ).setShowFindArtifacts( false ); archivaConfiguration.save( configuration ); - assertTrue( "Check file exists", baseFile.exists() ); + assertTrue( "Check file exists", baseFile.exists( ) ); assertEquals( "Check base file is unchanged", "", FileUtils.readFileToString( baseFile, null ) ); - assertTrue( "Check file exists", userFile.exists() ); + assertTrue( "Check file exists", userFile.exists( ) ); assertFalse( "Check base file is changed", "".equals( FileUtils.readFileToString( userFile, null ) ) ); // check it - configuration = archivaConfiguration.getConfiguration(); - assertFalse( "check value", configuration.getWebapp().getUi().isShowFindArtifacts() ); + configuration = archivaConfiguration.getConfiguration( ); + assertFalse( "check value", configuration.getWebapp( ).getUi( ).isShowFindArtifacts( ) ); } @Test - public void testStoreConfigurationFailsWhenReadFromBothLocationsAppserverHasLists() + public void testStoreConfigurationFailsWhenReadFromBothLocationsAppserverHasLists( ) throws Exception { File baseFile = getTestFile( "target/test/test-file.xml" ); - baseFile.delete(); - assertFalse( baseFile.exists() ); + baseFile.delete( ); + assertFalse( baseFile.exists( ) ); File userFile = getTestFile( "target/test/test-file-user.xml" ); - userFile.delete(); - assertFalse( userFile.exists() ); + userFile.delete( ); + assertFalse( userFile.exists( ) ); - baseFile.getParentFile().mkdirs(); + baseFile.getParentFile( ).mkdirs( ); FileUtils.copyFile( getTestFile( "src/test/conf/conf-base.xml" ), baseFile ); - userFile.getParentFile().mkdirs(); + userFile.getParentFile( ).mkdirs( ); FileUtils.writeStringToFile( userFile, "", null ); ArchivaConfiguration archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class, "test-save-user" ); - archivaConfiguration.reload(); + archivaConfiguration.reload( ); - Configuration configuration = archivaConfiguration.getConfiguration(); - assertTrue( "check value", configuration.getWebapp().getUi().isAppletFindEnabled() ); + Configuration configuration = archivaConfiguration.getConfiguration( ); + assertTrue( "check value", configuration.getWebapp( ).getUi( ).isAppletFindEnabled( ) ); - configuration.getWebapp().getUi().setAppletFindEnabled( false ); + configuration.getWebapp( ).getUi( ).setAppletFindEnabled( false ); try { @@ -535,18 +539,18 @@ public class ArchivaConfigurationTest catch ( IndeterminateConfigurationException e ) { // check it was reverted - configuration = archivaConfiguration.getConfiguration(); - assertTrue( "check value", configuration.getWebapp().getUi().isAppletFindEnabled() ); + configuration = archivaConfiguration.getConfiguration( ); + assertTrue( "check value", configuration.getWebapp( ).getUi( ).isAppletFindEnabled( ) ); } } @Test - public void testLoadConfigurationFromInvalidBothLocationsOnDisk() + public void testLoadConfigurationFromInvalidBothLocationsOnDisk( ) throws Exception { ArchivaConfiguration archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class, "test-not-allowed-to-write-to-both" ); - Configuration config = archivaConfiguration.getConfiguration(); + Configuration config = archivaConfiguration.getConfiguration( ); try { @@ -560,76 +564,107 @@ public class ArchivaConfigurationTest } @Test - public void testLoadConfigurationFromInvalidUserLocationOnDisk() + public void testLoadConfigurationFromInvalidUserLocationOnDisk( ) throws Exception { File testConfDir = getTestFile( "target/test-appserver-base/conf/" ); - testConfDir.mkdirs(); + testConfDir.mkdirs( ); ArchivaConfiguration archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class, "test-not-allowed-to-write-to-user" ); - Configuration config = archivaConfiguration.getConfiguration(); + Configuration config = archivaConfiguration.getConfiguration( ); archivaConfiguration.save( config ); // No Exception == test passes. // Expected Path is: Should not have thrown an exception. } @Test - public void testConfigurationUpgradeFrom09() + public void testConfigurationUpgradeFrom09( ) throws Exception { ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-upgrade-09" ); // we just use the defaults when upgrading from 0.9 at this point. - Configuration configuration = archivaConfiguration.getConfiguration(); + Configuration configuration = archivaConfiguration.getConfiguration( ); // test-upgrade-09 contains a managed with id: local so it's 3 managed assertConfiguration( configuration, 3, 1, 1 ); - assertEquals( "check network proxies", 0, configuration.getNetworkProxies().size() ); + assertEquals( "check network proxies", 0, configuration.getNetworkProxies( ).size( ) ); + + ManagedRepositoryConfiguration repository = configuration.getManagedRepositories( ).get( 0 ); + + assertEquals( "check managed repositories", "${appserver.base}/data/repositories/internal", + repository.getLocation( ) ); + assertEquals( "check managed repositories", "Archiva Managed Internal Repository", repository.getName( ) ); + assertEquals( "check managed repositories", "internal", repository.getId( ) ); + assertEquals( "check managed repositories", "default", repository.getLayout( ) ); + assertTrue( "check managed repositories", repository.isScanned( ) ); + } + + @Test + public void testConfigurationUpgradeFrom13( ) + throws Exception + { + ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-upgrade-1.3" ); + + // we just use the defaults when upgrading from 1.3 at this point. + Configuration configuration = archivaConfiguration.getConfiguration( ); + assertConfiguration( configuration, 2, 2, 2 ); + assertEquals( "check network proxies", 0, configuration.getNetworkProxies( ).size( ) ); - ManagedRepositoryConfiguration repository = configuration.getManagedRepositories().get( 0 ); + ManagedRepositoryConfiguration repository = configuration.getManagedRepositories( ).get( 0 ); assertEquals( "check managed repositories", "${appserver.base}/data/repositories/internal", - repository.getLocation() ); - assertEquals( "check managed repositories", "Archiva Managed Internal Repository", repository.getName() ); - assertEquals( "check managed repositories", "internal", repository.getId() ); - assertEquals( "check managed repositories", "default", repository.getLayout() ); - assertTrue( "check managed repositories", repository.isScanned() ); + repository.getLocation( ) ); + assertEquals( "check managed repositories", "Archiva Managed Internal Repository", repository.getName( ) ); + assertEquals( "check managed repositories", "internal", repository.getId( ) ); + assertEquals( "check managed repositories", "default", repository.getLayout( ) ); + assertTrue( "check managed repositories", repository.isScanned( ) ); + + log.info( "knowContentConsumers " + configuration.getRepositoryScanning( ).getKnownContentConsumers( ) ); + + assertFalse( + configuration.getRepositoryScanning( ).getKnownContentConsumers( ).contains( "update-db-artifact" ) ); + assertFalse( configuration.getRepositoryScanning( ).getKnownContentConsumers( ).contains( + "update-db-repository-metadata" ) ); + + assertTrue( + configuration.getRepositoryScanning( ).getKnownContentConsumers( ).contains( "create-archiva-metadata" ) ); } @Test - public void testAutoDetectV1() + public void testAutoDetectV1( ) throws Exception { // Setup the autodetect-v1.xml file in the target directory (so we can save/load it) File userFile = getTestFile( "target/test-autodetect-v1/archiva-user.xml" ); - userFile.delete(); - assertFalse( userFile.exists() ); + userFile.delete( ); + assertFalse( userFile.exists( ) ); - userFile.getParentFile().mkdirs(); + userFile.getParentFile( ).mkdirs( ); FileUtils.copyFile( getTestFile( "src/test/conf/autodetect-v1.xml" ), userFile ); // Load the original (unconverted) archiva.xml ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-autodetect-v1" ); - archivaConfiguration.reload(); + archivaConfiguration.reload( ); - Configuration configuration = archivaConfiguration.getConfiguration(); + Configuration configuration = archivaConfiguration.getConfiguration( ); assertConfiguration( configuration, 2, 2, 2 ); - assertEquals( "check network proxies", 1, configuration.getNetworkProxies().size() ); + assertEquals( "check network proxies", 1, configuration.getNetworkProxies( ).size( ) ); - ManagedRepositoryConfiguration repository = configuration.getManagedRepositories().get( 0 ); + ManagedRepositoryConfiguration repository = configuration.getManagedRepositories( ).get( 0 ); assertEquals( "check managed repositories", "${appserver.base}/repositories/internal", - repository.getLocation() ); - assertEquals( "check managed repositories", "Archiva Managed Internal Repository", repository.getName() ); - assertEquals( "check managed repositories", "internal", repository.getId() ); - assertEquals( "check managed repositories", "default", repository.getLayout() ); - assertTrue( "check managed repositories", repository.isScanned() ); + repository.getLocation( ) ); + assertEquals( "check managed repositories", "Archiva Managed Internal Repository", repository.getName( ) ); + assertEquals( "check managed repositories", "internal", repository.getId( ) ); + assertEquals( "check managed repositories", "default", repository.getLayout( ) ); + assertTrue( "check managed repositories", repository.isScanned( ) ); // Test that only 1 set of repositories exist. - assertEquals( "check managed repositories size.", 2, configuration.getManagedRepositories().size() ); - assertEquals( "check remote repositories size.", 2, configuration.getRemoteRepositories().size() ); - assertEquals( "check v1 repositories size.", 0, configuration.getRepositories().size() ); + assertEquals( "check managed repositories size.", 2, configuration.getManagedRepositories( ).size( ) ); + assertEquals( "check remote repositories size.", 2, configuration.getRemoteRepositories( ).size( ) ); + assertEquals( "check v1 repositories size.", 0, configuration.getRepositories( ).size( ) ); // Save the file. archivaConfiguration.save( configuration ); @@ -639,14 +674,14 @@ public class ArchivaConfigurationTest // Reload. archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class, "test-autodetect-v1" ); - configuration = archivaConfiguration.getConfiguration(); + configuration = archivaConfiguration.getConfiguration( ); // Test that only 1 set of repositories exist. - assertEquals( "check managed repositories size.", 2, configuration.getManagedRepositories().size() ); - assertEquals( "check managed repositories size.", 2, configuration.getManagedRepositoriesAsMap().size() ); - assertEquals( "check remote repositories size.", 2, configuration.getRemoteRepositories().size() ); - assertEquals( "check remote repositories size.", 2, configuration.getRemoteRepositoriesAsMap().size() ); - assertEquals( "check v1 repositories size.", 0, configuration.getRepositories().size() ); + assertEquals( "check managed repositories size.", 2, configuration.getManagedRepositories( ).size( ) ); + assertEquals( "check managed repositories size.", 2, configuration.getManagedRepositoriesAsMap( ).size( ) ); + assertEquals( "check remote repositories size.", 2, configuration.getRemoteRepositories( ).size( ) ); + assertEquals( "check remote repositories size.", 2, configuration.getRemoteRepositoriesAsMap( ).size( ) ); + assertEquals( "check v1 repositories size.", 0, configuration.getRepositories( ).size( ) ); String actualXML = FileUtils.readFileToString( userFile, null ); XMLAssert.assertXpathNotExists( "//configuration/repositories/repository", actualXML ); @@ -654,199 +689,199 @@ public class ArchivaConfigurationTest } @Test - public void testArchivaV1() + public void testArchivaV1( ) throws Exception { ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-archiva-v1" ); - Configuration configuration = archivaConfiguration.getConfiguration(); + Configuration configuration = archivaConfiguration.getConfiguration( ); assertConfiguration( configuration, 2, 2, 2 ); - assertEquals( "check network proxies", 1, configuration.getNetworkProxies().size() ); + assertEquals( "check network proxies", 1, configuration.getNetworkProxies( ).size( ) ); - assertEquals( "check managed repositories", 2, configuration.getManagedRepositories().size() ); - assertEquals( "check v1 repositories size.", 0, configuration.getRepositories().size() ); + assertEquals( "check managed repositories", 2, configuration.getManagedRepositories( ).size( ) ); + assertEquals( "check v1 repositories size.", 0, configuration.getRepositories( ).size( ) ); - Map map = configuration.getManagedRepositoriesAsMap(); + Map map = configuration.getManagedRepositoriesAsMap( ); ManagedRepositoryConfiguration repository = map.get( "internal" ); assertEquals( "check managed repositories", "${appserver.base}/repositories/internal", - repository.getLocation() ); - assertEquals( "check managed repositories", "Archiva Managed Internal Repository", repository.getName() ); - assertEquals( "check managed repositories", "internal", repository.getId() ); - assertEquals( "check managed repositories", "default", repository.getLayout() ); - assertTrue( "check managed repositories", repository.isScanned() ); - assertFalse( "check managed repositories", repository.isSnapshots() ); + repository.getLocation( ) ); + assertEquals( "check managed repositories", "Archiva Managed Internal Repository", repository.getName( ) ); + assertEquals( "check managed repositories", "internal", repository.getId( ) ); + assertEquals( "check managed repositories", "default", repository.getLayout( ) ); + assertTrue( "check managed repositories", repository.isScanned( ) ); + assertFalse( "check managed repositories", repository.isSnapshots( ) ); repository = map.get( "snapshots" ); assertEquals( "check managed repositories", "${appserver.base}/repositories/snapshots", - repository.getLocation() ); - assertEquals( "check managed repositories", "Archiva Managed Snapshot Repository", repository.getName() ); - assertEquals( "check managed repositories", "snapshots", repository.getId() ); - assertEquals( "check managed repositories", "default", repository.getLayout() ); - assertFalse( "check managed repositories", repository.isScanned() ); - assertTrue( "check managed repositories", repository.isSnapshots() ); + repository.getLocation( ) ); + assertEquals( "check managed repositories", "Archiva Managed Snapshot Repository", repository.getName( ) ); + assertEquals( "check managed repositories", "snapshots", repository.getId( ) ); + assertEquals( "check managed repositories", "default", repository.getLayout( ) ); + assertFalse( "check managed repositories", repository.isScanned( ) ); + assertTrue( "check managed repositories", repository.isSnapshots( ) ); } @Test - public void testCronExpressionsWithComma() + public void testCronExpressionsWithComma( ) throws Exception { File baseFile = getTestFile( "target/test/test-file.xml" ); - baseFile.delete(); - assertFalse( baseFile.exists() ); + baseFile.delete( ); + assertFalse( baseFile.exists( ) ); File userFile = getTestFile( "target/test/test-file-user.xml" ); - userFile.delete(); - assertFalse( userFile.exists() ); + userFile.delete( ); + assertFalse( userFile.exists( ) ); - baseFile.getParentFile().mkdirs(); + baseFile.getParentFile( ).mkdirs( ); FileUtils.copyFile( getTestFile( "src/test/conf/escape-cron-expressions.xml" ), baseFile ); - userFile.getParentFile().mkdirs(); + userFile.getParentFile( ).mkdirs( ); FileUtils.writeStringToFile( userFile, "", null ); final ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-cron-expressions" ); - archivaConfiguration.reload(); + archivaConfiguration.reload( ); - Configuration configuration = archivaConfiguration.getConfiguration(); + Configuration configuration = archivaConfiguration.getConfiguration( ); ManagedRepositoryConfiguration repository = - (ManagedRepositoryConfiguration) configuration.getManagedRepositories().get( 0 ); + (ManagedRepositoryConfiguration) configuration.getManagedRepositories( ).get( 0 ); - assertEquals( "check cron expression", "0 0,30 * * * ?", repository.getRefreshCronExpression().trim() ); + assertEquals( "check cron expression", "0 0,30 * * * ?", repository.getRefreshCronExpression( ).trim( ) ); // add a test listener to confirm it doesn't see the escaped format. We don't need to test the number of calls, // etc. as it's done in other tests - archivaConfiguration.addListener( new ConfigurationListener() + archivaConfiguration.addListener( new ConfigurationListener( ) { public void configurationEvent( ConfigurationEvent event ) { - assertEquals( ConfigurationEvent.SAVED, event.getType() ); + assertEquals( ConfigurationEvent.SAVED, event.getType( ) ); } } ); archivaConfiguration.save( configuration ); - configuration = archivaConfiguration.getConfiguration(); + configuration = archivaConfiguration.getConfiguration( ); // test for the escape character '\' showing up on repositories.jsp repository.setRefreshCronExpression( "0 0,20 0 * * ?" ); archivaConfiguration.save( configuration ); - repository = archivaConfiguration.getConfiguration().findManagedRepositoryById( "snapshots" ); + repository = archivaConfiguration.getConfiguration( ).findManagedRepositoryById( "snapshots" ); - assertEquals( "check cron expression", "0 0,20 0 * * ?", repository.getRefreshCronExpression() ); + assertEquals( "check cron expression", "0 0,20 0 * * ?", repository.getRefreshCronExpression( ) ); } @Test - public void testRemoveLastElements() + public void testRemoveLastElements( ) throws Exception { File baseFile = getTestFile( "target/test/test-file.xml" ); - baseFile.delete(); - assertFalse( baseFile.exists() ); + baseFile.delete( ); + assertFalse( baseFile.exists( ) ); File userFile = getTestFile( "target/test/test-file-user.xml" ); - userFile.delete(); - assertFalse( userFile.exists() ); + userFile.delete( ); + assertFalse( userFile.exists( ) ); - baseFile.getParentFile().mkdirs(); + baseFile.getParentFile( ).mkdirs( ); FileUtils.copyFile( getTestFile( "src/test/conf/conf-single-list-elements.xml" ), baseFile ); - userFile.getParentFile().mkdirs(); + userFile.getParentFile( ).mkdirs( ); FileUtils.writeStringToFile( userFile, "", null ); ArchivaConfiguration archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class, "test-remove-central" ); - archivaConfiguration.reload(); + archivaConfiguration.reload( ); - Configuration configuration = archivaConfiguration.getConfiguration(); + Configuration configuration = archivaConfiguration.getConfiguration( ); RepositoryGroupConfiguration repositoryGroup = - (RepositoryGroupConfiguration) configuration.getRepositoryGroups().get( 0 ); + (RepositoryGroupConfiguration) configuration.getRepositoryGroups( ).get( 0 ); assertNotNull( repositoryGroup ); configuration.removeRepositoryGroup( repositoryGroup ); - assertTrue( configuration.getRepositoryGroups().isEmpty() ); + assertTrue( configuration.getRepositoryGroups( ).isEmpty( ) ); - RemoteRepositoryConfiguration repository = configuration.getRemoteRepositoriesAsMap().get( "central" ); + RemoteRepositoryConfiguration repository = configuration.getRemoteRepositoriesAsMap( ).get( "central" ); assertNotNull( repository ); configuration.removeRemoteRepository( repository ); - assertTrue( configuration.getRemoteRepositories().isEmpty() ); + assertTrue( configuration.getRemoteRepositories( ).isEmpty( ) ); ManagedRepositoryConfiguration managedRepository = - configuration.getManagedRepositoriesAsMap().get( "snapshots" ); + configuration.getManagedRepositoriesAsMap( ).get( "snapshots" ); assertNotNull( managedRepository ); configuration.removeManagedRepository( managedRepository ); - assertTrue( configuration.getManagedRepositories().isEmpty() ); + assertTrue( configuration.getManagedRepositories( ).isEmpty( ) ); ProxyConnectorConfiguration proxyConnector = - (ProxyConnectorConfiguration) configuration.getProxyConnectors().get( 0 ); + (ProxyConnectorConfiguration) configuration.getProxyConnectors( ).get( 0 ); assertNotNull( proxyConnector ); configuration.removeProxyConnector( proxyConnector ); - assertTrue( configuration.getProxyConnectors().isEmpty() ); + assertTrue( configuration.getProxyConnectors( ).isEmpty( ) ); - NetworkProxyConfiguration networkProxy = configuration.getNetworkProxiesAsMap().get( "proxy" ); + NetworkProxyConfiguration networkProxy = configuration.getNetworkProxiesAsMap( ).get( "proxy" ); assertNotNull( networkProxy ); configuration.removeNetworkProxy( networkProxy ); - assertTrue( configuration.getNetworkProxies().isEmpty() ); + assertTrue( configuration.getNetworkProxies( ).isEmpty( ) ); - LegacyArtifactPath path = (LegacyArtifactPath) configuration.getLegacyArtifactPaths().get( 0 ); + LegacyArtifactPath path = (LegacyArtifactPath) configuration.getLegacyArtifactPaths( ).get( 0 ); assertNotNull( path ); configuration.removeLegacyArtifactPath( path ); - assertTrue( configuration.getLegacyArtifactPaths().isEmpty() ); + assertTrue( configuration.getLegacyArtifactPaths( ).isEmpty( ) ); - RepositoryScanningConfiguration scanning = configuration.getRepositoryScanning(); - String consumer = (String) scanning.getKnownContentConsumers().get( 0 ); + RepositoryScanningConfiguration scanning = configuration.getRepositoryScanning( ); + String consumer = (String) scanning.getKnownContentConsumers( ).get( 0 ); assertNotNull( consumer ); scanning.removeKnownContentConsumer( consumer ); - assertTrue( scanning.getKnownContentConsumers().isEmpty() ); - consumer = (String) scanning.getInvalidContentConsumers().get( 0 ); + assertTrue( scanning.getKnownContentConsumers( ).isEmpty( ) ); + consumer = (String) scanning.getInvalidContentConsumers( ).get( 0 ); assertNotNull( consumer ); scanning.removeInvalidContentConsumer( consumer ); - assertTrue( scanning.getInvalidContentConsumers().isEmpty() ); + assertTrue( scanning.getInvalidContentConsumers( ).isEmpty( ) ); archivaConfiguration.save( configuration ); archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class, "test-read-saved" ); - configuration = archivaConfiguration.getConfiguration(); - assertNull( configuration.getRemoteRepositoriesAsMap().get( "central" ) ); - assertTrue( configuration.getRepositoryGroups().isEmpty() ); - assertNull( configuration.getManagedRepositoriesAsMap().get( "snapshots" ) ); - assertTrue( configuration.getProxyConnectors().isEmpty() ); - assertNull( configuration.getNetworkProxiesAsMap().get( "proxy" ) ); - assertTrue( configuration.getLegacyArtifactPaths().isEmpty() ); - scanning = configuration.getRepositoryScanning(); - assertTrue( scanning.getKnownContentConsumers().isEmpty() ); - assertTrue( scanning.getInvalidContentConsumers().isEmpty() ); + configuration = archivaConfiguration.getConfiguration( ); + assertNull( configuration.getRemoteRepositoriesAsMap( ).get( "central" ) ); + assertTrue( configuration.getRepositoryGroups( ).isEmpty( ) ); + assertNull( configuration.getManagedRepositoriesAsMap( ).get( "snapshots" ) ); + assertTrue( configuration.getProxyConnectors( ).isEmpty( ) ); + assertNull( configuration.getNetworkProxiesAsMap( ).get( "proxy" ) ); + assertTrue( configuration.getLegacyArtifactPaths( ).isEmpty( ) ); + scanning = configuration.getRepositoryScanning( ); + assertTrue( scanning.getKnownContentConsumers( ).isEmpty( ) ); + assertTrue( scanning.getInvalidContentConsumers( ).isEmpty( ) ); } /** * [MRM-582] Remote Repositories with empty and fields shouldn't be created in configuration. */ @Test - public void testGetConfigurationFixEmptyRemoteRepoUsernamePassword() + public void testGetConfigurationFixEmptyRemoteRepoUsernamePassword( ) throws Exception { ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-configuration" ); - archivaConfiguration.reload(); - Configuration configuration = archivaConfiguration.getConfiguration(); + archivaConfiguration.reload( ); + Configuration configuration = archivaConfiguration.getConfiguration( ); assertConfiguration( configuration, 2, 2, 2 ); - assertEquals( "check remote repositories", 2, configuration.getRemoteRepositories().size() ); + assertEquals( "check remote repositories", 2, configuration.getRemoteRepositories( ).size( ) ); RemoteRepositoryConfiguration repository = - configuration.getRemoteRepositoriesAsMap().get( "maven2-repository.dev.java.net" ); + configuration.getRemoteRepositoriesAsMap( ).get( "maven2-repository.dev.java.net" ); assertEquals( "remote repository.url", "https://maven2-repository.dev.java.net/nonav/repository", - repository.getUrl() ); - assertEquals( "remote repository.name", "Java.net Repository for Maven 2", repository.getName() ); - assertEquals( "remote repository.id", "maven2-repository.dev.java.net", repository.getId() ); - assertEquals( "remote repository.layout", "default", repository.getLayout() ); - assertNull( "remote repository.username == null", repository.getUsername() ); - assertNull( "remote repository.password == null", repository.getPassword() ); + repository.getUrl( ) ); + assertEquals( "remote repository.name", "Java.net Repository for Maven 2", repository.getName( ) ); + assertEquals( "remote repository.id", "maven2-repository.dev.java.net", repository.getId( ) ); + assertEquals( "remote repository.layout", "default", repository.getLayout( ) ); + assertNull( "remote repository.username == null", repository.getUsername( ) ); + assertNull( "remote repository.password == null", repository.getPassword( ) ); } } diff --git a/archiva-modules/archiva-base/archiva-configuration/src/test/resources/spring-context.xml b/archiva-modules/archiva-base/archiva-configuration/src/test/resources/spring-context.xml index fdf125589..ce8d0e883 100755 --- a/archiva-modules/archiva-base/archiva-configuration/src/test/resources/spring-context.xml +++ b/archiva-modules/archiva-base/archiva-configuration/src/test/resources/spring-context.xml @@ -55,6 +55,23 @@ + + + + + + + + + + + ]]> + + + +