From d3e88a986a8161b69f7302988ce73be92e582eb5 Mon Sep 17 00:00:00 2001 From: "Edwin L. Punzalan" Date: Wed, 15 Mar 2006 10:27:57 +0000 Subject: [PATCH] PR: MRM-107 Removed classes from maven-proxy that may not be required at all. git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@386036 13f79535-47bb-0310-9956-ffa450edef68 --- .../configuration/FileRepoConfiguration.java | 50 --- .../GlobalRepoConfiguration.java | 14 - .../configuration/HttpRepoConfiguration.java | 64 ---- .../MavenProxyConfiguration.java | 54 --- .../MavenProxyConfigurationReader.java | 67 ---- .../MavenProxyPropertyLoader.java | 249 ++++---------- .../MavenProxyRepoConfiguration.java | 30 -- .../configuration/RepoConfiguration.java | 110 ------- .../RetrievalComponentConfiguration.java | 311 ------------------ .../proxy/repository/ProxyRepository.java | 2 +- .../src/test/conf/maven-proxy-complete.conf | 288 ++++++++-------- .../MavenProxyPropertyLoaderTest.java | 103 ++++++ .../configuration/ProxyConfigurationTest.java | 68 +--- 13 files changed, 312 insertions(+), 1098 deletions(-) delete mode 100644 maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/FileRepoConfiguration.java delete mode 100644 maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/GlobalRepoConfiguration.java delete mode 100644 maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/HttpRepoConfiguration.java delete mode 100644 maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/MavenProxyConfiguration.java delete mode 100644 maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/MavenProxyConfigurationReader.java delete mode 100644 maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/MavenProxyRepoConfiguration.java delete mode 100644 maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/RepoConfiguration.java delete mode 100644 maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/RetrievalComponentConfiguration.java create mode 100644 maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/configuration/MavenProxyPropertyLoaderTest.java diff --git a/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/FileRepoConfiguration.java b/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/FileRepoConfiguration.java deleted file mode 100644 index 000e15944..000000000 --- a/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/FileRepoConfiguration.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.apache.maven.repository.proxy.configuration; - -/* - * Copyright 2003-2004 The Apache Software Foundation. - * - * Licensed 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 java.io.File; - -/** - * Strips file:/// off the front of the configured URL and uses that to find files locally. - * - * @author Ben Walding - */ -public class FileRepoConfiguration - extends RepoConfiguration -{ - private final String basePath; - - public FileRepoConfiguration( String key, String url, String description, boolean copy, boolean hardFail, - boolean cacheFailures, long cachePeriod ) - { - super( key, url, description, copy, hardFail, cacheFailures, cachePeriod ); - basePath = url.substring( 8 ); - } - - public String getBasePath() - { - return basePath; - } - - /** - * Given a relative path, returns the absolute file in the repository - */ - public File getLocalFile( String path ) - { - return new File( basePath + path ); - } -} \ No newline at end of file diff --git a/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/GlobalRepoConfiguration.java b/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/GlobalRepoConfiguration.java deleted file mode 100644 index 23cf8241d..000000000 --- a/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/GlobalRepoConfiguration.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.apache.maven.repository.proxy.configuration; - -/** - * @author Ben Walding - */ -public class GlobalRepoConfiguration - extends FileRepoConfiguration -{ - public GlobalRepoConfiguration( String basePath ) - { - super( "global", "file:///" + basePath, "Global Repository", false, true, false, 0 ); - } - -} \ No newline at end of file diff --git a/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/HttpRepoConfiguration.java b/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/HttpRepoConfiguration.java deleted file mode 100644 index a7f4510c5..000000000 --- a/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/HttpRepoConfiguration.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.apache.maven.repository.proxy.configuration; - -/* - * Copyright 2003-2004 The Apache Software Foundation. - * - * Licensed 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. - */ - -/** - * @author Ben Walding - */ -public class HttpRepoConfiguration - extends RepoConfiguration -{ - private final String username; - - private final String password; - - private final MavenProxyConfiguration proxy; - - public HttpRepoConfiguration( String key, String url, String description, String username, String password, - boolean hardFail, MavenProxyConfiguration proxy, boolean cacheFailures, - long cachePeriod ) - { - super( key, url, description, true, hardFail, cacheFailures, cachePeriod ); - this.username = username; - this.password = password; - this.proxy = proxy; - } - - /** - * - */ - public String getPassword() - { - return password; - } - - /** - * - */ - public String getUsername() - { - return username; - } - - /** - * - */ - public MavenProxyConfiguration getProxy() - { - return proxy; - } -} \ No newline at end of file diff --git a/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/MavenProxyConfiguration.java b/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/MavenProxyConfiguration.java deleted file mode 100644 index 7ee4164a4..000000000 --- a/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/MavenProxyConfiguration.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.apache.maven.repository.proxy.configuration; - -/** - * Immutable. - * - * @author Ben Walding - */ -public class MavenProxyConfiguration -{ - private final String key; - - private final String host; - - private final int port; - - private final String username; - - private final String password; - - public MavenProxyConfiguration( String key, String host, int port, String username, String password ) - { - this.key = key; - this.host = host; - this.port = port; - this.username = username; - this.password = password; - } - - public String getHost() - { - return host; - } - - public String getKey() - { - return key; - } - - public String getPassword() - { - return password; - } - - public int getPort() - { - return port; - } - - public String getUsername() - { - return username; - } - -} diff --git a/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/MavenProxyConfigurationReader.java b/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/MavenProxyConfigurationReader.java deleted file mode 100644 index d5831bb68..000000000 --- a/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/MavenProxyConfigurationReader.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.apache.maven.repository.proxy.configuration; - -import org.apache.maven.repository.proxy.repository.ProxyRepository; -import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; - -import java.io.File; -import java.io.IOException; -import java.io.FileInputStream; -import java.util.List; -import java.util.ArrayList; -import java.util.Iterator; - -/** - * @author Edwin Punzalan - */ -public class MavenProxyConfigurationReader -{ - /** - * Uses maven-proxy classes to read a maven-proxy properties configuration - * - * @param mavenProxyConfigurationFile The location of the maven-proxy configuration file - * @throws ValidationException When a problem occured while processing the properties file - * @throws java.io.IOException When a problem occured while reading the property file - */ - public ProxyConfiguration loadMavenProxyConfiguration( File mavenProxyConfigurationFile ) - throws ValidationException, IOException - { - ProxyConfiguration configuration = new ProxyConfiguration(); - - MavenProxyPropertyLoader loader = new MavenProxyPropertyLoader(); - RetrievalComponentConfiguration rcc = loader.load( new FileInputStream( mavenProxyConfigurationFile ) ); - - configuration.setRepositoryCachePath( rcc.getLocalStore() ); - - List repoList = new ArrayList(); - for ( Iterator repos = rcc.getRepos().iterator(); repos.hasNext(); ) - { - RepoConfiguration repoConfig = (RepoConfiguration) repos.next(); - - //skip local store repo - if ( !repoConfig.getKey().equals( "global" ) ) - { - ProxyRepository repo = new ProxyRepository( repoConfig.getKey(), repoConfig.getUrl(), new DefaultRepositoryLayout() ); - repo.setCacheFailures( repoConfig.getCacheFailures() ); - repo.setCachePeriod( repoConfig.getCachePeriod() ); - repo.setHardfail( repoConfig.getHardFail() ); - - if ( repoConfig instanceof HttpRepoConfiguration ) - { - HttpRepoConfiguration httpRepo = (HttpRepoConfiguration) repoConfig; - MavenProxyConfiguration httpProxy = httpRepo.getProxy(); - //todo put into the configuration the proxy - if ( httpProxy != null ) - { - repo.setProxied( true ); - } - } - - repoList.add( repo ); - } - } - - configuration.setRepositories( repoList ); - - return configuration; - } -} diff --git a/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/MavenProxyPropertyLoader.java b/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/MavenProxyPropertyLoader.java index 19726efab..5de33d295 100644 --- a/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/MavenProxyPropertyLoader.java +++ b/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/MavenProxyPropertyLoader.java @@ -16,9 +16,14 @@ package org.apache.maven.repository.proxy.configuration; * limitations under the License. */ +import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; +import org.apache.maven.repository.proxy.repository.ProxyRepository; +import org.codehaus.plexus.util.StringUtils; + import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.util.ArrayList; import java.util.Enumeration; import java.util.Iterator; import java.util.List; @@ -30,113 +35,57 @@ import java.util.StringTokenizer; */ public class MavenProxyPropertyLoader { + private static final String REPO_LOCAL_STORE = "repo.local.store"; - public static final String REPO_LOCAL_STORE = "repo.local.store"; + private static final String PROXY_LIST = "proxy.list"; - public static final String REPO_CUSTOM_STORE = "repo.custom.store"; + private static final String REPO_LIST = "repo.list"; - public static final String PORT = "port"; - - public static final String SNAPSHOT_UPDATE = "snapshot.update"; - - public static final String SNAPSHOT_CACHE_FAILURES = "snapshot.cache.failures"; - - public static final String METADATA_UPDATE = "metadata.update"; - - public static final String POM_UPDATE = "pom.update"; - - public static final int DEFAULT_PORT = 4321; - - public static final String LAST_MODIFIED_DATE_FORMAT = "lastModifiedDateFormat"; - - public static final String DEFAULT_LAST_MODIFIED_DATE_FORMAT = null; - - public static final String BROWSABLE = "browsable"; - - public static final String SEARCHABLE = "searchable"; - - public static final String STYLESHEET = "stylesheet"; - - public static final String BGCOLOR = "css.bgColor"; - - public static final String BGCOLORHIGHLIGHT = "css.bgColorHighlight"; - - public static final String ROWCOLOR = "css.rowColor"; - - public static final String ROWCOLORHIGHLIGHT = "css.rowColorHighlight"; - - public static final String PREFIX = "prefix"; - - private static final String SERVERNAME = "serverName"; - - public RetrievalComponentConfiguration load( Properties props ) + public ProxyConfiguration load( Properties props ) throws ValidationException { - RetrievalComponentConfiguration rcc = new RetrievalComponentConfiguration(); + ProxyConfiguration config = new ProxyConfiguration(); - String localStore = getMandatoryProperty( props, REPO_LOCAL_STORE ); - GlobalRepoConfiguration globalRepo = new GlobalRepoConfiguration( localStore ); - rcc.setLocalStore( localStore ); - rcc.addRepo( globalRepo ); + config.setLayout( "default" ); - if ( props.getProperty( PORT ) == null ) - { - rcc.setPort( DEFAULT_PORT ); - } - else - { - try - { - rcc.setPort( Integer.parseInt( props.getProperty( PORT ) ) ); - } - catch ( NumberFormatException ex ) - { - throw new ValidationException( "Property " + PORT + " must be a integer" ); - } - } + config.setRepositoryCachePath( getMandatoryProperty( props, REPO_LOCAL_STORE ) ); - rcc.setSnapshotUpdate( Boolean.valueOf( getMandatoryProperty( props, SNAPSHOT_UPDATE ) ).booleanValue() ); - rcc.setMetaDataUpdate( - Boolean.valueOf( getOptionalProperty( props, METADATA_UPDATE, "true" ) ).booleanValue() ); - rcc.setPOMUpdate( Boolean.valueOf( getOptionalProperty( props, POM_UPDATE, "false" ) ).booleanValue() ); - - rcc.setBrowsable( Boolean.valueOf( getMandatoryProperty( props, BROWSABLE ) ).booleanValue() ); - rcc.setSearchable( Boolean.valueOf( getOptionalProperty( props, SEARCHABLE, "true" ) ).booleanValue() ); - rcc.setServerName( props.getProperty( SERVERNAME ) ); - rcc.setPrefix( getMandatoryProperty( props, PREFIX ) ); - rcc.setLastModifiedDateFormat( props.getProperty( LAST_MODIFIED_DATE_FORMAT ) ); - rcc.setStylesheet( getOptionalProperty( props, STYLESHEET, null ) ); - rcc.setBgColor( getOptionalProperty( props, BGCOLOR, "#14B" ) ); - rcc.setBgColorHighlight( getOptionalProperty( props, BGCOLORHIGHLIGHT, "#9BF" ) ); - rcc.setRowColor( getOptionalProperty( props, ROWCOLOR, "#CCF" ) ); - rcc.setRowColorHighlight( getOptionalProperty( props, ROWCOLORHIGHLIGHT, "#DDF" ) ); - - if ( rcc.getPrefix().length() == 0 ) - { - //System.err.println( "Using an empty 'prefix' is deprecated behaviour. Please set a prefix." ); - } - - { - String propertyList = props.getProperty( "proxy.list" ); + {//just get the first proxy and break + String propertyList = props.getProperty( PROXY_LIST ); if ( propertyList != null ) { StringTokenizer tok = new StringTokenizer( propertyList, "," ); while ( tok.hasMoreTokens() ) { String key = tok.nextToken(); - String host = getMandatoryProperty( props, "proxy." + key + ".host" ); - int port = Integer.parseInt( getMandatoryProperty( props, "proxy." + key + ".port" ) ); - // the username and password isn't required - String username = props.getProperty( "proxy." + key + ".username" ); - String password = props.getProperty( "proxy." + key + ".password" ); - MavenProxyConfiguration pc = new MavenProxyConfiguration( key, host, port, username, password ); - rcc.addProxy( pc ); + if ( StringUtils.isNotEmpty( key ) ) + { + String host = getMandatoryProperty( props, "proxy." + key + ".host" ); + int port = Integer.parseInt( getMandatoryProperty( props, "proxy." + key + ".port" ) ); + + // the username and password isn't required + String username = props.getProperty( "proxy." + key + ".username" ); + String password = props.getProperty( "proxy." + key + ".password" ); + + if ( StringUtils.isNotEmpty( username ) ) + { + config.setHttpProxy( host, port, username, password ); + } + else + { + config.setHttpProxy( host, port ); + } + + //accept only one proxy configuration + break; + } } } } - { - String repoList = getMandatoryProperty( props, "repo.list" ); + List repositories = new ArrayList(); + { //get the remote repository list + String repoList = getMandatoryProperty( props, REPO_LIST ); StringTokenizer tok = new StringTokenizer( repoList, "," ); while ( tok.hasMoreTokens() ) @@ -145,97 +94,39 @@ public class MavenProxyPropertyLoader Properties repoProps = getSubset( props, "repo." + key + "." ); String url = getMandatoryProperty( props, "repo." + key + ".url" ); - // the username, password and proxy are not mandatory - String username = repoProps.getProperty( "username" ); - String password = repoProps.getProperty( "password" ); - String description = repoProps.getProperty( "description" ); String proxyKey = repoProps.getProperty( "proxy" ); - Boolean cacheFailures = Boolean.valueOf( repoProps.getProperty( "cache.failures", "false" ) ); - Long cachePeriod = Long.valueOf( repoProps.getProperty( "cache.period", "0" ) ); - Boolean hardFail = Boolean.valueOf( repoProps.getProperty( "hardfail", "true" ) ); + boolean cacheFailures = Boolean.valueOf( repoProps.getProperty( "cache.failures", "false" ) ).booleanValue(); + boolean hardFail = Boolean.valueOf( repoProps.getProperty( "hardfail", "true" ) ).booleanValue(); + long cachePeriod = Long.parseLong( repoProps.getProperty( "cache.period", "0" ) ); - MavenProxyConfiguration proxy = null; - if ( proxyKey != null ) + ProxyRepository repository = + new ProxyRepository( key, url, new DefaultRepositoryLayout(), cacheFailures, cachePeriod ); + + repository.setHardfail( hardFail ); + + if ( StringUtils.isNotEmpty( proxyKey ) ) { - proxy = rcc.getProxy( proxyKey ); + repository.setProxied( true ); } - if ( description == null || description.trim().length() == 0 ) - { - description = key; - } - - RepoConfiguration rc = null; - - if ( url.startsWith( "http://" ) ) - { - rc = new HttpRepoConfiguration( key, url, description, username, password, hardFail.booleanValue(), - proxy, cacheFailures.booleanValue(), cachePeriod.longValue() ); - } - - if ( url.startsWith( "file:///" ) ) - { - boolean copy = "true".equalsIgnoreCase( repoProps.getProperty( "copy" ) ); - rc = new FileRepoConfiguration( key, url, description, copy, hardFail.booleanValue(), cacheFailures - .booleanValue(), cachePeriod.longValue() ); - } - - if ( rc == null ) - { - throw new ValidationException( "Unknown upstream repository type: " + url ); - } - - rcc.addRepo( rc ); + repositories.add( repository ); } } - validateDirectories( rcc ); - validateLocalRepo( rcc ); - validateRemoteRepo( rcc ); - return rcc; + config.setRepositories( repositories ); + validateDirectories( config ); + validateRemoteRepo( config ); + + return config; } - /** - * Checks to make sure a specific value is set - * - * @throws ValidationException if value is null - */ - private String checkSet( String value, String propertyName ) - throws ValidationException - { - if ( value == null ) - { - throw new ValidationException( "Missing property '" + propertyName + "'" ); - } - - return value; - } - - private void validateLocalRepo( RetrievalComponentConfiguration rcc ) - throws ValidationException - { - //Verify local repository set - String tmp = checkSet( rcc.getLocalStore(), MavenProxyPropertyLoader.REPO_LOCAL_STORE ); - - File file = new File( tmp ); - if ( !file.exists() ) - { - throw new ValidationException( "The local repository doesn't exist: " + file.getAbsolutePath() ); - } - - if ( !file.isDirectory() ) - { - throw new ValidationException( "The local repository must be a directory: " + file.getAbsolutePath() ); - } - } - - private void validateRemoteRepo( RetrievalComponentConfiguration rcc ) + private void validateRemoteRepo( ProxyConfiguration configuration ) throws ValidationException { //Verify remote repository set //only warn if missing - if ( rcc.getRepos().size() < 1 ) + if ( configuration.getRepositories().size() < 1 ) { throw new ValidationException( "At least one remote repository must be configured." ); } @@ -258,7 +149,7 @@ public class MavenProxyPropertyLoader return result; } - public RetrievalComponentConfiguration load( InputStream is ) + public ProxyConfiguration load( InputStream is ) throws IOException, ValidationException { Properties props = new Properties(); @@ -279,35 +170,21 @@ public class MavenProxyPropertyLoader return value; } - private String getOptionalProperty( Properties props, String key, String defaultValue ) - { - final String value = props.getProperty( key ); - - if ( value == null ) - { - return defaultValue; - } - - return value; - } - - private void validateDirectories( RetrievalComponentConfiguration rcc ) + private void validateDirectories( ProxyConfiguration configuration ) throws ValidationException { - File f = new File( rcc.getLocalStore() ); + File f = new File( configuration.getRepositoryCachePath() ); if ( !f.exists() ) { throw new ValidationException( "Specified directory does not exist: " + f.getAbsolutePath() ); } - List repos = rcc.getRepos(); - for ( Iterator iter = repos.iterator(); iter.hasNext(); ) + for ( Iterator repos = configuration.getRepositories().iterator(); repos.hasNext(); ) { - RepoConfiguration repo = (RepoConfiguration) iter.next(); - if ( repo instanceof FileRepoConfiguration ) + ProxyRepository repo = (ProxyRepository) repos.next(); + if ( repo.getUrl().startsWith( "file://" ) ) { - FileRepoConfiguration fileRepo = (FileRepoConfiguration) repo; - File f2 = new File( fileRepo.getBasePath() ); + File f2 = new File( repo.getBasedir() ); if ( !f2.exists() ) { throw new ValidationException( "Specified directory does not exist: " + f2.getAbsolutePath() ); diff --git a/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/MavenProxyRepoConfiguration.java b/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/MavenProxyRepoConfiguration.java deleted file mode 100644 index e6b3ed43e..000000000 --- a/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/MavenProxyRepoConfiguration.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.apache.maven.repository.proxy.configuration; - -/* - * Copyright 2005-2006 The Apache Software Foundation. - * - * Licensed 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. - */ - -/** - * @author Edwin Punzalan - */ -public class MavenProxyRepoConfiguration - extends RepoConfiguration -{ - public MavenProxyRepoConfiguration( String key, String url, String description, boolean copy, boolean hardFail, - boolean cacheFailures, long cachePeriod ) - { - super( key, url, description, copy, hardFail, cacheFailures, cachePeriod ); - } -} diff --git a/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/RepoConfiguration.java b/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/RepoConfiguration.java deleted file mode 100644 index e3783d163..000000000 --- a/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/RepoConfiguration.java +++ /dev/null @@ -1,110 +0,0 @@ -package org.apache.maven.repository.proxy.configuration; - -/* - * Copyright 2003-2004 The Apache Software Foundation. - * - * Licensed 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.codehaus.plexus.logging.AbstractLogEnabled; - -/** - * Immutable. - *

- * hardfail - if a repository is set to hard fail, then the download engine will terminate the whole download - * process (with a status 500) if any of the repositories have unexpected errors. - *

- * if a repository expects an error - eg. 400 (not found) - then it is not required to terminate the - * download process. - * - * @author Ben Walding - */ -public abstract class RepoConfiguration - extends AbstractLogEnabled -{ - private final String key; - - private final String description; - - private final String url; - - private final boolean copy; - - private final boolean hardFail; - - private final boolean cacheFailures; - - private final long cachePeriod; - - public RepoConfiguration( String key, String url, String description, boolean copy, boolean hardFail, - boolean cacheFailures, long cachePeriod ) - { - this.key = key; - this.url = url; - this.description = description; - this.copy = copy; - this.hardFail = hardFail; - this.cacheFailures = cacheFailures; - this.cachePeriod = cachePeriod; - } - - /** - * - */ - public String getUrl() - { - return url; - } - - /** - * - */ - public String getKey() - { - return key; - } - - /** - * If a file repository is set to "copy" mode, it will copy the found files into - * the main repository store. - */ - public boolean getCopy() - { - return copy; - } - - public String getDescription() - { - return description; - } - - public boolean getHardFail() - { - return hardFail; - } - - public boolean getCacheFailures() - { - return cacheFailures; - } - - public long getCachePeriod() - { - return cachePeriod; - } - - public String toString() - { - return "Repo[" + getKey() + "]"; - } -} \ No newline at end of file diff --git a/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/RetrievalComponentConfiguration.java b/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/RetrievalComponentConfiguration.java deleted file mode 100644 index e4a0fa39e..000000000 --- a/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/RetrievalComponentConfiguration.java +++ /dev/null @@ -1,311 +0,0 @@ -package org.apache.maven.repository.proxy.configuration; - -/* - * Copyright 2005-2006 The Apache Software Foundation. - * - * Licensed 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 java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.TimeZone; - -/** - * @author Ben Walding - */ -public class RetrievalComponentConfiguration -{ - private final Map proxies = new HashMap(); - - private final List repos = new ArrayList(); - - private String localStore; - - private String serverName; - - private String bgColor; - - private String bgColorHighlight; - - private String rowColor; - - private String rowColorHighlight; - - private String stylesheet; - - private boolean searchable; - - private boolean browsable; - - private int port; - - private String prefix; - - private boolean snapshotUpdate; - - private boolean metaDataUpdate; - - private boolean pomUpdate; - - private String lastModifiedDateFormat; - - public String getPrefix() - { - return prefix; - } - - public void setPrefix( String prefix ) - { - this.prefix = prefix; - } - - /** - * @return - */ - public boolean isBrowsable() - { - return browsable; - } - - /** - * @param browsable - */ - public void setBrowsable( boolean browsable ) - { - this.browsable = browsable; - } - - public int getPort() - { - return port; - } - - public void setPort( int port ) - { - this.port = port; - } - - /** - * @return - */ - public String getLocalStore() - { - return localStore; - } - - /** - * @param localStore - */ - public void setLocalStore( String localStore ) - { - this.localStore = localStore; - } - - public void addProxy( MavenProxyConfiguration pc ) - { - proxies.put( pc.getKey(), pc ); - } - - public void removeProxy( String key ) - { - proxies.remove( key ); - } - - public MavenProxyConfiguration getProxy( String key ) - { - return (MavenProxyConfiguration) proxies.get( key ); - } - - /** - * There is no specific order to proxy configuration. - * - * @return - */ - public List getProxies() - { - return new ArrayList( proxies.values() ); - } - - public void addRepo( RepoConfiguration repo ) - { - repos.add( repo ); - } - - public List getRepos() - { - return Collections.unmodifiableList( repos ); - } - - public String getServerName() - { - return serverName; - } - - public void setServerName( String serverName ) - { - this.serverName = serverName; - } - - public void setSnapshotUpdate( boolean snapshotUpdate ) - { - this.snapshotUpdate = snapshotUpdate; - } - - public boolean getSnapshotUpdate() - { - return snapshotUpdate; - } - - public void setMetaDataUpdate( boolean metaDataUpdate ) - { - this.metaDataUpdate = metaDataUpdate; - } - - public boolean getMetaDataUpdate() - { - return metaDataUpdate; - } - - public void setPOMUpdate( boolean pomUpdate ) - { - this.pomUpdate = pomUpdate; - } - - public boolean getPOMUpdate() - { - return pomUpdate; - } - - public String getLastModifiedDateFormat() - { - return lastModifiedDateFormat; - } - - public void setLastModifiedDateFormat( String lastModifiedDateFormat ) - { - this.lastModifiedDateFormat = lastModifiedDateFormat; - } - - public boolean isSearchable() - { - return searchable; - } - - public void setSearchable( boolean searchable ) - { - this.searchable = searchable; - } - - /** - * @return the global repo configuration - */ - public GlobalRepoConfiguration getGlobalRepo() - { - for ( Iterator iter = repos.iterator(); iter.hasNext(); ) - { - RepoConfiguration repo = (RepoConfiguration) iter.next(); - if ( repo instanceof GlobalRepoConfiguration ) - { - return (GlobalRepoConfiguration) repo; - } - } - return null; - } - - private ThreadLocal dateFormatThreadLocal = new ThreadLocal() - { - protected synchronized Object initialValue() - { - DateFormat df; - - if ( getLastModifiedDateFormat() == null || getLastModifiedDateFormat() == "" ) - { - df = new SimpleDateFormat(); - } - else - { - df = new SimpleDateFormat( getLastModifiedDateFormat() ); - } - - df.setTimeZone( TimeZone.getTimeZone( "GMT" ) ); - return df; - } - }; - - /** - * Retrieves and casts the appropriate DateFormat object from a ThreadLocal - * - * @return - */ - public DateFormat getLastModifiedDateFormatForThread() - { - return (DateFormat) dateFormatThreadLocal.get(); - } - - public String getBgColor() - { - return bgColor; - } - - public void setBgColor( String bgColor ) - { - this.bgColor = bgColor; - } - - public String getBgColorHighlight() - { - return bgColorHighlight; - } - - public void setBgColorHighlight( String bgColorHighlight ) - { - this.bgColorHighlight = bgColorHighlight; - } - - public String getStylesheet() - { - return stylesheet; - } - - public void setStylesheet( String stylesheet ) - { - this.stylesheet = stylesheet; - } - - public String getRowColor() - { - return rowColor; - } - - public void setRowColor( String rowColor ) - { - this.rowColor = rowColor; - } - - public String getRowColorHighlight() - { - return rowColorHighlight; - } - - public void setRowColorHighlight( String rowColorHighlight ) - { - this.rowColorHighlight = rowColorHighlight; - } - -} \ No newline at end of file diff --git a/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/repository/ProxyRepository.java b/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/repository/ProxyRepository.java index 37fd2110c..9e2ae73e9 100644 --- a/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/repository/ProxyRepository.java +++ b/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/repository/ProxyRepository.java @@ -33,7 +33,7 @@ public class ProxyRepository private boolean cacheFailures = false; - private boolean hardfail = false; + private boolean hardfail = true; private boolean proxied = false; diff --git a/maven-repository-proxy/src/test/conf/maven-proxy-complete.conf b/maven-repository-proxy/src/test/conf/maven-proxy-complete.conf index d32682efb..7908a9ad9 100644 --- a/maven-repository-proxy/src/test/conf/maven-proxy-complete.conf +++ b/maven-repository-proxy/src/test/conf/maven-proxy-complete.conf @@ -1,144 +1,144 @@ -################ GLOBAL SETTINGS -# This is where maven-proxy stores files it has downloaded -repo.local.store=target - -#The port to listen on - not used if loaded as a webapp -port=9999 - -#This is the base area that all files are loaded from. While it is possible to leave this blank, this behaviour -#is deprecated and will be disabled in version 2.0. There are too many namespace conflicts caused by not using -#a prefix. -#The repository will be shown at http://localhost:9999/repository/ -#for the .war loaded into a webapp server, the default prefix is "repository" (edit the web.xml to change) -# As maven doesn't like a trailing slash, this address shouldn't have one either. -prefix=repository - -#This is the simple date format used to display the last modified date while browsing the repository. -lastModifiedDateFormat=yyyy/MM/dd HH:mm:ss - -################ SNAPSHOT HANDLING -#If you want the proxy to look for newer snapshots, set to true -snapshot.update=true - -################ M2 METADATA HANDLING -#If you want the proxy to prevent looking for newer metadata, set to false (default is true) -#metadata.update=false - -################ M2 POM HANDLING -#If you want the proxy to look for newer POMs, set to true (default is false) -pom.update=true - -################ PROMOTION HANDLING -# ***** NOT CURRENTLY IMPLEMENTED ***** -#Promotion describes the process by which new artifacts are loaded to global maven-proxy repository. It -# is designed to be used by "higher security installations" that do not want to acquire artifacts from -# remote repositories without approval. -# -#If promotion handling is enabled, then the proxy will not download remote artifacts without permission -# (local repositories with copy=false are considered to be local) -# -#Permission to download is granted via the Promotion menu which will be enabled -# when promotion handling is enabled. -# -#If promotion is false, artifacts are sourced from any repository as per normal. -# -#Promotion and snapshots: If promotion is enabled, snapshots are not downloadable. The concept of using -# a snapshot in a production build (which is primarily what promotion is for) is counterintuitive. -## -promotion=false - -################ WEB INTERFACE -# This defines the absolute URL the server should use to identify itself. -# This can often be determined automatically, but we recommend you specify -# it explicitly to prevent problems during startup. -# The prefix will be added to this for the actual repository -# i.e. proxy available at http://localhost:9999/, repository at http://localhost:9999/repository -serverName=http://localhost:9999 - -#If true, the repository can be browsed -browsable=true - -#If true, the repository can be searched -searchable=true - -#Not currently implemented. Will allow webdav access to the repository at some point. -webdav=true - -#Stylesheet - if configured, will override the default stylesheet shipped with maven-proxy - absolute URLs only -#eg. /maven-proxy/style.css, http://www.example.com/style.css -stylesheet=/maven-proxy/style.css - -#bgColor / bgColorHighlight are replaced in the built in stylesheet to produce a simple color scheme. -#If a stylesheet is set, these are not used. -bgColor=#14B -bgColorHighlight=#94B - -#rowColor / rowColorHighlight are replaced in the built in stylesheet to produce a simple color scheme. -#If a stylesheet is set, these are not used. -rowColor=#CCF -rowColorHighlight=#DDF - - -################ PROXIES -#This is just a hack, it should auto discover them -proxy.list=one,two,three - -#Unauthenticated proxy -proxy.one.host=proxy1.example.com -proxy.one.port=3128 - -#Authenticated proxy -proxy.two.host=proxy2.example.org -proxy.two.port=80 -proxy.two.username=username2 -proxy.two.password=password2 - -#Authenticated proxy -proxy.three.host=proxy3.example.net -proxy.three.port=3129 -proxy.three.username=username3 -proxy.three.password=password3 - - -################# REPOSITORIES -#This is not just a hack, it specifies the order repositories should be checked -#Note that the proxy adds a "/" which is why the urls aren't suffixed with a "/" -repo.list=local-repo,www-ibiblio-org,dist-codehaus-org,private-example-com - -#local-store -# The local store represents a location that local jars you host can be located. -# This could also be achieved by having a local http repository, but this is less cumbersome -repo.local-repo.url=file:///./target/remote-repo1 -repo.local-repo.description=Super Secret Custom Repository -#If copy is true, jars are copied from the store to the proxy-repo. Only configurable for file:/// repos -repo.local-repo.copy=false -#If hardfail is true, any unexpected errors from the repository will cause -#the client download to fail (typically with a 500 error) -repo.local-repo.hardfail=true -#Don't cache a file repository -repo.local-repo.cache.period=0 - - -#www.ibiblio.org -repo.www-ibiblio-org.url=http://www.ibiblio.org/maven2 -repo.www-ibiblio-org.description=www.ibiblio.org -repo.www-ibiblio-org.proxy=one -repo.www-ibiblio-org.hardfail=true -#Cache this repository for 1 hour -repo.www-ibiblio-org.cache.period=3600 -repo.www-ibiblio-org.cache.failures=true - -#dist.codehaus.org -repo.dist-codehaus-org.url=http://dist.codehaus.org -repo.dist-codehaus-org.proxy=two -repo.dist-codehaus-org.hardfail=false -repo.dist-codehaus-org.cache.period=3600 -repo.dist-codehaus-org.cache.failures=true - -#private.example.com -repo.private-example-com.url=http://private.example.com/internal -repo.private-example-com.description=Commercial In Confidence Repository -repo.private-example-com.username=username1 -repo.private-example-com.password=password1 -repo.private-example-com.proxy=three -repo.private-example-com.cache.period=3600 +################ GLOBAL SETTINGS +# This is where maven-proxy stores files it has downloaded +repo.local.store=target + +#The port to listen on - not used if loaded as a webapp +port=9999 + +#This is the base area that all files are loaded from. While it is possible to leave this blank, this behaviour +#is deprecated and will be disabled in version 2.0. There are too many namespace conflicts caused by not using +#a prefix. +#The repository will be shown at http://localhost:9999/repository/ +#for the .war loaded into a webapp server, the default prefix is "repository" (edit the web.xml to change) +# As maven doesn't like a trailing slash, this address shouldn't have one either. +prefix=repository + +#This is the simple date format used to display the last modified date while browsing the repository. +lastModifiedDateFormat=yyyy/MM/dd HH:mm:ss + +################ SNAPSHOT HANDLING +#If you want the proxy to look for newer snapshots, set to true +snapshot.update=true + +################ M2 METADATA HANDLING +#If you want the proxy to prevent looking for newer metadata, set to false (default is true) +#metadata.update=false + +################ M2 POM HANDLING +#If you want the proxy to look for newer POMs, set to true (default is false) +pom.update=true + +################ PROMOTION HANDLING +# ***** NOT CURRENTLY IMPLEMENTED ***** +#Promotion describes the process by which new artifacts are loaded to global maven-proxy repository. It +# is designed to be used by "higher security installations" that do not want to acquire artifacts from +# remote repositories without approval. +# +#If promotion handling is enabled, then the proxy will not download remote artifacts without permission +# (local repositories with copy=false are considered to be local) +# +#Permission to download is granted via the Promotion menu which will be enabled +# when promotion handling is enabled. +# +#If promotion is false, artifacts are sourced from any repository as per normal. +# +#Promotion and snapshots: If promotion is enabled, snapshots are not downloadable. The concept of using +# a snapshot in a production build (which is primarily what promotion is for) is counterintuitive. +## +promotion=false + +################ WEB INTERFACE +# This defines the absolute URL the server should use to identify itself. +# This can often be determined automatically, but we recommend you specify +# it explicitly to prevent problems during startup. +# The prefix will be added to this for the actual repository +# i.e. proxy available at http://localhost:9999/, repository at http://localhost:9999/repository +serverName=http://localhost:9999 + +#If true, the repository can be browsed +browsable=true + +#If true, the repository can be searched +searchable=true + +#Not currently implemented. Will allow webdav access to the repository at some point. +webdav=true + +#Stylesheet - if configured, will override the default stylesheet shipped with maven-proxy - absolute URLs only +#eg. /maven-proxy/style.css, http://www.example.com/style.css +stylesheet=/maven-proxy/style.css + +#bgColor / bgColorHighlight are replaced in the built in stylesheet to produce a simple color scheme. +#If a stylesheet is set, these are not used. +bgColor=#14B +bgColorHighlight=#94B + +#rowColor / rowColorHighlight are replaced in the built in stylesheet to produce a simple color scheme. +#If a stylesheet is set, these are not used. +rowColor=#CCF +rowColorHighlight=#DDF + + +################ PROXIES +#This is just a hack, it should auto discover them +proxy.list=one,two,three + +#Unauthenticated proxy +proxy.one.host=proxy1.example.com +proxy.one.port=3128 + +#Authenticated proxy +proxy.two.host=proxy2.example.org +proxy.two.port=80 +proxy.two.username=username2 +proxy.two.password=password2 + +#Authenticated proxy +proxy.three.host=proxy3.example.net +proxy.three.port=3129 +proxy.three.username=username3 +proxy.three.password=password3 + + +################# REPOSITORIES +#This is not just a hack, it specifies the order repositories should be checked +#Note that the proxy adds a "/" which is why the urls aren't suffixed with a "/" +repo.list=local-repo,www-ibiblio-org,dist-codehaus-org,private-example-com + +#local-store +# The local store represents a location that local jars you host can be located. +# This could also be achieved by having a local http repository, but this is less cumbersome +repo.local-repo.url=file://target +repo.local-repo.description=Super Secret Custom Repository +#If copy is true, jars are copied from the store to the proxy-repo. Only configurable for file:/// repos +repo.local-repo.copy=false +#If hardfail is true, any unexpected errors from the repository will cause +#the client download to fail (typically with a 500 error) +repo.local-repo.hardfail=true +#Don't cache a file repository +repo.local-repo.cache.period=0 + + +#www.ibiblio.org +repo.www-ibiblio-org.url=http://www.ibiblio.org/maven2 +repo.www-ibiblio-org.description=www.ibiblio.org +repo.www-ibiblio-org.proxy=one +repo.www-ibiblio-org.hardfail=true +#Cache this repository for 1 hour +repo.www-ibiblio-org.cache.period=3600 +repo.www-ibiblio-org.cache.failures=true + +#dist.codehaus.org +repo.dist-codehaus-org.url=http://dist.codehaus.org +repo.dist-codehaus-org.proxy=two +repo.dist-codehaus-org.hardfail=false +repo.dist-codehaus-org.cache.period=3600 +repo.dist-codehaus-org.cache.failures=true + +#private.example.com +repo.private-example-com.url=http://private.example.com/internal +repo.private-example-com.description=Commercial In Confidence Repository +repo.private-example-com.username=username1 +repo.private-example-com.password=password1 +repo.private-example-com.proxy=three +repo.private-example-com.cache.period=3600 diff --git a/maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/configuration/MavenProxyPropertyLoaderTest.java b/maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/configuration/MavenProxyPropertyLoaderTest.java new file mode 100644 index 000000000..b64ba8eea --- /dev/null +++ b/maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/configuration/MavenProxyPropertyLoaderTest.java @@ -0,0 +1,103 @@ +package org.apache.maven.repository.proxy.configuration; + +/* + * Copyright 2005-2006 The Apache Software Foundation. + * + * Licensed 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.maven.repository.proxy.repository.ProxyRepository; +import org.codehaus.plexus.PlexusTestCase; +import org.codehaus.plexus.util.FileUtils; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.Iterator; + + +/** + * @author Edwin Punzalan + */ +public class MavenProxyPropertyLoaderTest + extends PlexusTestCase +{ + public void testLoadValidMavenProxyConfiguration() + throws ValidationException, IOException + { + MavenProxyPropertyLoader loader = new MavenProxyPropertyLoader(); + + //must create the test directory bec configuration is using relative path which varies + FileUtils.mkdir( "target/remote-repo1" ); + + try + { + File confFile = getTestFile( "src/test/conf/maven-proxy-complete.conf" ); + + ProxyConfiguration config = loader.load( new FileInputStream( confFile ) ); + + assertTrue( "cache path changed", config.getRepositoryCachePath().endsWith( "target" ) ); + + assertEquals( "Count repositories", 4, config.getRepositories().size() ); + + int idx = 0; + for ( Iterator repos = config.getRepositories().iterator(); repos.hasNext(); ) + { + idx++; + + ProxyRepository repo = (ProxyRepository) repos.next(); + + //switch is made to check for ordering + switch ( idx ) + { + case 1: + assertEquals( "Repository name not as expected", "local-repo", repo.getKey() ); + assertEquals( "Repository url does not match its name", "file://target", + repo.getUrl() ); + assertEquals( "Repository cache period check failed", 0, repo.getCachePeriod() ); + assertFalse( "Repository failure caching check failed", repo.isCacheFailures() ); + break; + case 2: + assertEquals( "Repository name not as expected", "www-ibiblio-org", repo.getKey() ); + assertEquals( "Repository url does not match its name", "http://www.ibiblio.org/maven2", + repo.getUrl() ); + assertEquals( "Repository cache period check failed", 3600, repo.getCachePeriod() ); + assertTrue( "Repository failure caching check failed", repo.isCacheFailures() ); + break; + case 3: + assertEquals( "Repository name not as expected", "dist-codehaus-org", repo.getKey() ); + assertEquals( "Repository url does not match its name", "http://dist.codehaus.org", + repo.getUrl() ); + assertEquals( "Repository cache period check failed", 3600, repo.getCachePeriod() ); + assertTrue( "Repository failure caching check failed", repo.isCacheFailures() ); + break; + case 4: + assertEquals( "Repository name not as expected", "private-example-com", repo.getKey() ); + assertEquals( "Repository url does not match its name", "http://private.example.com/internal", + repo.getUrl() ); + assertEquals( "Repository cache period check failed", 3600, repo.getCachePeriod() ); + assertFalse( "Repository failure caching check failed", repo.isCacheFailures() ); + break; + default: + fail( "Unexpected order count" ); + } + } + } + //make sure to delete the test directory after tests + finally + { + FileUtils.deleteDirectory( "target/remote-repo1" ); + } + } + +} diff --git a/maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/configuration/ProxyConfigurationTest.java b/maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/configuration/ProxyConfigurationTest.java index 6fa469369..491e8bf19 100644 --- a/maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/configuration/ProxyConfigurationTest.java +++ b/maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/configuration/ProxyConfigurationTest.java @@ -79,7 +79,7 @@ public class ProxyConfigurationTest assertEquals( "repo2", repo.getId() ); assertEquals( "http://www.ibiblio.org/maven", repo.getUrl() ); assertFalse( repo.isCacheFailures() ); - assertFalse( repo.isHardfail() ); + assertTrue( repo.isHardfail() ); assertEquals( 3600, repo.getCachePeriod() ); assertEquals( repo2, repo ); assertTrue( repo.isProxied() ); @@ -108,72 +108,6 @@ public class ProxyConfigurationTest assertEquals( repositories, config.getRepositories() ); } -// public void testLoadValidMavenProxyConfiguration() -// throws ValidationException, IOException -// { -// //must create the test directory bec configuration is using relative path which varies -// FileUtils.mkdir( "target/remote-repo1" ); -// -// try -// { -// File confFile = getTestFile( "src/test/conf/maven-proxy-complete.conf" ); -// -// config.loadMavenProxyConfiguration( confFile ); -// -// assertTrue( "cache path changed", config.getRepositoryCachePath().endsWith( "target" ) ); -// -// assertEquals( "Count repositories", 4, config.getRepositories().size() ); -// -// int idx = 0; -// for ( Iterator repos = config.getRepositories().iterator(); repos.hasNext(); ) -// { -// idx++; -// -// ProxyRepository repo = (ProxyRepository) repos.next(); -// -// //switch is made to check for ordering -// switch ( idx ) -// { -// case 1: -// assertEquals( "Repository name not as expected", "local-repo", repo.getKey() ); -// assertEquals( "Repository url does not match its name", "file:///./target/remote-repo1", -// repo.getUrl() ); -// assertEquals( "Repository cache period check failed", 0, repo.getCachePeriod() ); -// assertFalse( "Repository failure caching check failed", repo.isCacheFailures() ); -// break; -// case 2: -// assertEquals( "Repository name not as expected", "www-ibiblio-org", repo.getKey() ); -// assertEquals( "Repository url does not match its name", "http://www.ibiblio.org/maven2", -// repo.getUrl() ); -// assertEquals( "Repository cache period check failed", 3600, repo.getCachePeriod() ); -// assertTrue( "Repository failure caching check failed", repo.isCacheFailures() ); -// break; -// case 3: -// assertEquals( "Repository name not as expected", "dist-codehaus-org", repo.getKey() ); -// assertEquals( "Repository url does not match its name", "http://dist.codehaus.org", -// repo.getUrl() ); -// assertEquals( "Repository cache period check failed", 3600, repo.getCachePeriod() ); -// assertTrue( "Repository failure caching check failed", repo.isCacheFailures() ); -// break; -// case 4: -// assertEquals( "Repository name not as expected", "private-example-com", repo.getKey() ); -// assertEquals( "Repository url does not match its name", "http://private.example.com/internal", -// repo.getUrl() ); -// assertEquals( "Repository cache period check failed", 3600, repo.getCachePeriod() ); -// assertFalse( "Repository failure caching check failed", repo.isCacheFailures() ); -// break; -// default: -// fail( "Unexpected order count" ); -// } -// } -// } -// //make sure to delete the test directory after tests -// finally -// { -// FileUtils.deleteDirectory( "target/remote-repo1" ); -// } -// } -// protected void tearDown() throws Exception {