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 assertEquals( cacheFile.getAbsolutePath(), cache.getBasedir() );
\r
56 assertEquals( config.getRepositoryCachePath(), cache.getBasedir() );
\r
59 public void testRepositories()
\r
61 ArtifactRepositoryLayout defLayout = new DefaultRepositoryLayout();
\r
62 ProxyRepository repo1 = new ProxyRepository( "repo1", "http://www.ibiblio.org/maven2", defLayout );
\r
63 config.addRepository( repo1 );
\r
64 assertEquals( 1, config.getRepositories().size() );
\r
66 ArtifactRepositoryLayout legacyLayout = new LegacyRepositoryLayout();
\r
67 ProxyRepository repo2 = new ProxyRepository( "repo2", "http://www.ibiblio.org/maven", legacyLayout );
\r
68 config.addRepository( repo2 );
\r
69 assertEquals( 2, config.getRepositories().size() );
\r
71 List repositories = config.getRepositories();
\r
72 ProxyRepository repo = (ProxyRepository) repositories.get( 0 );
\r
73 assertEquals( repo1, repo );
\r
75 repo = (ProxyRepository) repositories.get( 1 );
\r
76 assertEquals( repo2, repo );
\r
80 repositories.add( new ProxyRepository( "repo", "url", defLayout ) );
\r
81 fail( "Expected UnsupportedOperationException not thrown." );
\r
83 catch ( java.lang.UnsupportedOperationException e )
\r
88 repositories = new ArrayList();
\r
89 repositories.add( repo1 );
\r
90 repositories.add( repo2 );
\r
91 config.setRepositories( repositories );
\r
92 assertEquals( repositories, config.getRepositories() );
\r
95 protected void tearDown()
\r