maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From epunza...@apache.org
Subject svn commit: r386036 - in /maven/repository-manager/trunk/maven-repository-proxy/src: main/java/org/apache/maven/repository/proxy/configuration/ main/java/org/apache/maven/repository/proxy/repository/ test/conf/ test/java/org/apache/maven/repository/pro...
Date Wed, 15 Mar 2006 10:27:59 GMT
Author: epunzalan
Date: Wed Mar 15 02:27:57 2006
New Revision: 386036

URL: http://svn.apache.org/viewcvs?rev=386036&view=rev
Log:
PR: MRM-107

Removed classes from maven-proxy that may not be required at all.

Added:
    maven/repository-manager/trunk/maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/configuration/MavenProxyPropertyLoaderTest.java
Removed:
    maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/FileRepoConfiguration.java
    maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/GlobalRepoConfiguration.java
    maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/HttpRepoConfiguration.java
    maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/MavenProxyConfiguration.java
    maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/MavenProxyConfigurationReader.java
    maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/MavenProxyRepoConfiguration.java
    maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/RepoConfiguration.java
    maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/RetrievalComponentConfiguration.java
Modified:
    maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/MavenProxyPropertyLoader.java
    maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/repository/ProxyRepository.java
    maven/repository-manager/trunk/maven-repository-proxy/src/test/conf/maven-proxy-complete.conf
    maven/repository-manager/trunk/maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/configuration/ProxyConfigurationTest.java

Modified: maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/MavenProxyPropertyLoader.java
URL: http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/MavenProxyPropertyLoader.java?rev=386036&r1=386035&r2=386036&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/MavenProxyPropertyLoader.java
(original)
+++ maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/MavenProxyPropertyLoader.java
Wed Mar 15 02:27:57 2006
@@ -16,9 +16,14 @@
  * 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 @@
  */
 public class MavenProxyPropertyLoader
 {
+    private static final String REPO_LOCAL_STORE = "repo.local.store";
 
-    public static final String REPO_LOCAL_STORE = "repo.local.store";
-
-    public static final String REPO_CUSTOM_STORE = "repo.custom.store";
-
-    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 PROXY_LIST = "proxy.list";
 
-    private static final String SERVERNAME = "serverName";
+    private static final String REPO_LIST = "repo.list";
 
-    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"
);
-            }
-        }
-
-        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" )
);
+        config.setRepositoryCachePath( getMandatoryProperty( props, REPO_LOCAL_STORE ) );
 
-        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 @@
 
                 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 )
-                {
-                    proxy = rcc.getProxy( proxyKey );
-                }
+                ProxyRepository repository =
+                    new ProxyRepository( key, url, new DefaultRepositoryLayout(), cacheFailures,
cachePeriod );
 
-                if ( description == null || description.trim().length() == 0 )
-                {
-                    description = key;
-                }
+                repository.setHardfail( hardFail );
 
-                RepoConfiguration rc = null;
-
-                if ( url.startsWith( "http://" ) )
+                if ( StringUtils.isNotEmpty( proxyKey ) )
                 {
-                    rc = new HttpRepoConfiguration( key, url, description, username, password,
hardFail.booleanValue(),
-                                                    proxy, cacheFailures.booleanValue(),
cachePeriod.longValue() );
+                    repository.setProxied( true );
                 }
 
-                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 );
 
-    /**
-     * 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 + "'" );
-        }
+        validateDirectories( config );
+        validateRemoteRepo( config );
 
-        return value;
+        return config;
     }
 
-    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 @@
         return result;
     }
 
-    public RetrievalComponentConfiguration load( InputStream is )
+    public ProxyConfiguration load( InputStream is )
         throws IOException, ValidationException
     {
         Properties props = new Properties();
@@ -279,35 +170,21 @@
         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() );

Modified: maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/repository/ProxyRepository.java
URL: http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/repository/ProxyRepository.java?rev=386036&r1=386035&r2=386036&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/repository/ProxyRepository.java
(original)
+++ maven/repository-manager/trunk/maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/repository/ProxyRepository.java
Wed Mar 15 02:27:57 2006
@@ -33,7 +33,7 @@
 
     private boolean cacheFailures = false;
 
-    private boolean hardfail = false;
+    private boolean hardfail = true;
 
     private boolean proxied = false;
 

Modified: maven/repository-manager/trunk/maven-repository-proxy/src/test/conf/maven-proxy-complete.conf
URL: http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-proxy/src/test/conf/maven-proxy-complete.conf?rev=386036&r1=386035&r2=386036&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-proxy/src/test/conf/maven-proxy-complete.conf
(original)
+++ maven/repository-manager/trunk/maven-repository-proxy/src/test/conf/maven-proxy-complete.conf
Wed Mar 15 02:27:57 2006
@@ -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

Added: maven/repository-manager/trunk/maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/configuration/MavenProxyPropertyLoaderTest.java
URL: http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/configuration/MavenProxyPropertyLoaderTest.java?rev=386036&view=auto
==============================================================================
--- maven/repository-manager/trunk/maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/configuration/MavenProxyPropertyLoaderTest.java
(added)
+++ maven/repository-manager/trunk/maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/configuration/MavenProxyPropertyLoaderTest.java
Wed Mar 15 02:27:57 2006
@@ -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" );
+        }
+    }
+
+}

Modified: maven/repository-manager/trunk/maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/configuration/ProxyConfigurationTest.java
URL: http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/configuration/ProxyConfigurationTest.java?rev=386036&r1=386035&r2=386036&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/configuration/ProxyConfigurationTest.java
(original)
+++ maven/repository-manager/trunk/maven-repository-proxy/src/test/java/org/apache/maven/repository/proxy/configuration/ProxyConfigurationTest.java
Wed Mar 15 02:27:57 2006
@@ -79,7 +79,7 @@
         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 @@
         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
     {



Mime
View raw message