1 package org.apache.maven.repository.proxy.configuration;
\r
4 * Copyright 2005-2006 The Apache Software Foundation.
\r
6 * Licensed under the Apache License, Version 2.0 (the "License");
\r
7 * you may not use this file except in compliance with the License.
\r
8 * You may obtain a copy of the License at
\r
10 * http://www.apache.org/licenses/LICENSE-2.0
\r
12 * Unless required by applicable law or agreed to in writing, software
\r
13 * distributed under the License is distributed on an "AS IS" BASIS,
\r
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
15 * See the License for the specific language governing permissions and
\r
16 * limitations under the License.
\r
19 import org.apache.maven.artifact.repository.ArtifactRepository;
\r
20 import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
\r
21 import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
\r
22 import org.apache.maven.artifact.repository.layout.LegacyRepositoryLayout;
\r
23 import org.apache.maven.repository.proxy.repository.ProxyRepository;
\r
24 import org.codehaus.plexus.PlexusTestCase;
\r
26 import java.io.File;
\r
27 import java.util.List;
\r
28 import java.util.ArrayList;
\r
30 public class ProxyConfigurationTest
\r
31 extends PlexusTestCase
\r
33 private ProxyConfiguration config;
\r
35 protected void setUp()
\r
40 config = (ProxyConfiguration) container.lookup( ProxyConfiguration.ROLE );
\r
43 public void testBrowsable()
\r
45 assertFalse( config.isBrowsable() );
\r
46 config.setBrowsable( true );
\r
47 assertTrue( config.isBrowsable() );
\r
50 public void testRepositoryCache()
\r
52 File cacheFile = new File( "target/proxy-cache" );
\r
53 config.setRepositoryCachePath( "file://" + cacheFile.getAbsolutePath() );
\r
54 ArtifactRepository cache = config.getRepositoryCache();
\r
55 System.out.println( cache.getUrl() );
\r
56 assertEquals( cacheFile.getAbsolutePath(), cache.getBasedir() );
\r
57 assertEquals( config.getRepositoryCachePath(), cache.getBasedir() );
\r
60 public void testRepositories()
\r
62 ArtifactRepositoryLayout defLayout = new DefaultRepositoryLayout();
\r
63 ProxyRepository repo1 = new ProxyRepository( "repo1", "http://www.ibiblio.org/maven2", defLayout );
\r
64 config.addRepository( repo1 );
\r
65 assertEquals( 1, config.getRepositories().size() );
\r
67 ArtifactRepositoryLayout legacyLayout = new LegacyRepositoryLayout();
\r
68 ProxyRepository repo2 = new ProxyRepository( "repo2", "http://www.ibiblio.org/maven", legacyLayout );
\r
69 config.addRepository( repo2 );
\r
70 assertEquals( 2, config.getRepositories().size() );
\r
72 List repositories = config.getRepositories();
\r
73 ProxyRepository repo = (ProxyRepository) repositories.get( 0 );
\r
74 assertEquals( repo1, repo );
\r
76 repo = (ProxyRepository) repositories.get( 1 );
\r
77 assertEquals( repo2, repo );
\r
81 repositories.add( new ProxyRepository( "repo", "url", defLayout ) );
\r
82 fail( "Expected UnsupportedOperationException not thrown." );
\r
84 catch ( java.lang.UnsupportedOperationException e )
\r
89 repositories = new ArrayList();
\r
90 repositories.add( repo1 );
\r
91 repositories.add( repo2 );
\r
92 config.setRepositories( repositories );
\r
93 assertEquals( repositories, config.getRepositories() );
\r
96 protected void tearDown()
\r