mirror of https://github.com/apache/archiva.git
use JUnit 4 API
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1136302 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
af8d62f38f
commit
9ae8d172b2
|
@ -19,11 +19,9 @@ package org.apache.maven.archiva.proxy;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
import net.sf.ehcache.CacheManager;
|
import net.sf.ehcache.CacheManager;
|
||||||
import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
|
import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
|
||||||
import org.apache.commons.lang.ArrayUtils;
|
import org.apache.commons.lang.ArrayUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||||
import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
|
import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
|
||||||
|
@ -47,7 +45,6 @@ import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
|
@ -59,6 +56,9 @@ import java.util.Calendar;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AbstractProxyTestCase
|
* AbstractProxyTestCase
|
||||||
|
@ -66,11 +66,9 @@ import java.util.Locale;
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
@RunWith( SpringJUnit4ClassRunner.class )
|
@RunWith( SpringJUnit4ClassRunner.class )
|
||||||
@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } )
|
@ContextConfiguration( locations = {"classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml"} )
|
||||||
public abstract class AbstractProxyTestCase
|
public abstract class AbstractProxyTestCase
|
||||||
extends TestCase
|
|
||||||
{
|
{
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected ApplicationContext applicationContext;
|
protected ApplicationContext applicationContext;
|
||||||
|
|
||||||
|
@ -134,21 +132,20 @@ public abstract class AbstractProxyTestCase
|
||||||
public void setUp()
|
public void setUp()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
super.setUp();
|
config = (MockConfiguration) applicationContext.getBean( "archivaConfiguration#mock",
|
||||||
|
ArchivaConfiguration.class );
|
||||||
config =
|
|
||||||
(MockConfiguration) applicationContext.getBean( "archivaConfiguration#mock", ArchivaConfiguration.class );
|
|
||||||
|
|
||||||
config.getConfiguration().setManagedRepositories( new ArrayList<ManagedRepositoryConfiguration>() );
|
config.getConfiguration().setManagedRepositories( new ArrayList<ManagedRepositoryConfiguration>() );
|
||||||
config.getConfiguration().setRemoteRepositories( new ArrayList<RemoteRepositoryConfiguration>() );
|
config.getConfiguration().setRemoteRepositories( new ArrayList<RemoteRepositoryConfiguration>() );
|
||||||
config.getConfiguration().setProxyConnectors( new ArrayList<ProxyConnectorConfiguration>() );
|
config.getConfiguration().setProxyConnectors( new ArrayList<ProxyConnectorConfiguration>() );
|
||||||
|
|
||||||
// Setup source repository (using default layout)
|
// Setup source repository (using default layout)
|
||||||
String repoPath = "target/test-repository/managed/" + getName();
|
String name = getClass().getSimpleName();
|
||||||
|
String repoPath = "target/test-repository/managed/" + name;
|
||||||
File repoLocation = new File( repoPath );
|
File repoLocation = new File( repoPath );
|
||||||
|
|
||||||
managedDefaultRepository =
|
managedDefaultRepository = createRepository( ID_DEFAULT_MANAGED, "Default Managed Repository", repoPath,
|
||||||
createRepository( ID_DEFAULT_MANAGED, "Default Managed Repository", repoPath, "default" );
|
"default" );
|
||||||
|
|
||||||
managedDefaultDir = new File( managedDefaultRepository.getRepoRoot() );
|
managedDefaultDir = new File( managedDefaultRepository.getRepoRoot() );
|
||||||
|
|
||||||
|
@ -158,17 +155,14 @@ public abstract class AbstractProxyTestCase
|
||||||
|
|
||||||
// Setup source repository (using legacy layout)
|
// Setup source repository (using legacy layout)
|
||||||
repoLocation = new File( REPOPATH_LEGACY_MANAGED_TARGET );
|
repoLocation = new File( REPOPATH_LEGACY_MANAGED_TARGET );
|
||||||
if (repoLocation.exists())
|
if ( repoLocation.exists() )
|
||||||
{
|
{
|
||||||
FileUtils.deleteDirectory( repoLocation );
|
FileUtils.deleteDirectory( repoLocation );
|
||||||
}
|
}
|
||||||
copyDirectoryStructure( new File( REPOPATH_LEGACY_MANAGED ), repoLocation );
|
copyDirectoryStructure( new File( REPOPATH_LEGACY_MANAGED ), repoLocation );
|
||||||
|
|
||||||
managedLegacyRepository =
|
managedLegacyRepository = createRepository( ID_LEGACY_MANAGED, "Legacy Managed Repository",
|
||||||
createRepository( ID_LEGACY_MANAGED, "Legacy Managed Repository", REPOPATH_LEGACY_MANAGED_TARGET,
|
REPOPATH_LEGACY_MANAGED_TARGET, "legacy" );
|
||||||
"legacy" );
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
managedLegacyDir = new File( managedLegacyRepository.getRepoRoot() );
|
managedLegacyDir = new File( managedLegacyRepository.getRepoRoot() );
|
||||||
|
|
||||||
|
@ -177,22 +171,21 @@ public abstract class AbstractProxyTestCase
|
||||||
config.getConfiguration().addManagedRepository( repoConfig );
|
config.getConfiguration().addManagedRepository( repoConfig );
|
||||||
|
|
||||||
// Setup target (proxied to) repository.
|
// Setup target (proxied to) repository.
|
||||||
saveRemoteRepositoryConfig( ID_PROXIED1, "Proxied Repository 1",
|
saveRemoteRepositoryConfig( ID_PROXIED1, "Proxied Repository 1", new File(
|
||||||
new File( REPOPATH_PROXIED1 ).toURL().toExternalForm(), "default" );
|
REPOPATH_PROXIED1 ).toURL().toExternalForm(), "default" );
|
||||||
|
|
||||||
// Setup target (proxied to) repository.
|
// Setup target (proxied to) repository.
|
||||||
saveRemoteRepositoryConfig( ID_PROXIED2, "Proxied Repository 2",
|
saveRemoteRepositoryConfig( ID_PROXIED2, "Proxied Repository 2", new File(
|
||||||
new File( REPOPATH_PROXIED2 ).toURL().toExternalForm(), "default" );
|
REPOPATH_PROXIED2 ).toURL().toExternalForm(), "default" );
|
||||||
|
|
||||||
// Setup target (proxied to) repository using legacy layout.
|
// Setup target (proxied to) repository using legacy layout.
|
||||||
saveRemoteRepositoryConfig( ID_LEGACY_PROXIED, "Proxied Legacy Repository",
|
saveRemoteRepositoryConfig( ID_LEGACY_PROXIED, "Proxied Legacy Repository", new File(
|
||||||
new File( REPOPATH_PROXIED_LEGACY ).toURL().toExternalForm(), "legacy" );
|
REPOPATH_PROXIED_LEGACY ).toURL().toExternalForm(), "legacy" );
|
||||||
|
|
||||||
// Setup the proxy handler.
|
// Setup the proxy handler.
|
||||||
//proxyHandler = applicationContext.getBean (RepositoryProxyConnectors) lookup( RepositoryProxyConnectors.class.getName() );
|
//proxyHandler = applicationContext.getBean (RepositoryProxyConnectors) lookup( RepositoryProxyConnectors.class.getName() );
|
||||||
|
|
||||||
proxyHandler =
|
proxyHandler = applicationContext.getBean( "repositoryProxyConnectors#test", RepositoryProxyConnectors.class );
|
||||||
applicationContext.getBean( "repositoryProxyConnectors#test", RepositoryProxyConnectors.class );
|
|
||||||
|
|
||||||
// Setup the wagon mock.
|
// Setup the wagon mock.
|
||||||
wagonMockControl = MockControl.createNiceControl( Wagon.class );
|
wagonMockControl = MockControl.createNiceControl( Wagon.class );
|
||||||
|
@ -204,13 +197,7 @@ public abstract class AbstractProxyTestCase
|
||||||
|
|
||||||
CacheManager.getInstance().clearAll();
|
CacheManager.getInstance().clearAll();
|
||||||
|
|
||||||
log.info( "\n.\\ " + getName() + "() \\._________________________________________\n" );
|
log.info( "\n.\\ " + name + "() \\._________________________________________\n" );
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName()
|
|
||||||
{
|
|
||||||
return StringUtils.substringAfterLast( getClass().getName(), "." );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static final ArgumentsMatcher customWagonGetIfNewerMatcher = new ArgumentsMatcher()
|
protected static final ArgumentsMatcher customWagonGetIfNewerMatcher = new ArgumentsMatcher()
|
||||||
|
@ -222,8 +209,8 @@ public abstract class AbstractProxyTestCase
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return MockControl.ARRAY_MATCHER.matches( ArrayUtils.remove( expected, 1 ),
|
return MockControl.ARRAY_MATCHER.matches( ArrayUtils.remove( expected, 1 ), ArrayUtils.remove( actual,
|
||||||
ArrayUtils.remove( actual, 1 ) );
|
1 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString( Object[] arguments )
|
public String toString( Object[] arguments )
|
||||||
|
@ -325,7 +312,7 @@ public abstract class AbstractProxyTestCase
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Collection<File> tmpFiles = org.apache.commons.io.FileUtils.listFiles( workingDir, new String[]{ "tmp" }, false );
|
Collection<File> tmpFiles = org.apache.commons.io.FileUtils.listFiles( workingDir, new String[]{"tmp"}, false );
|
||||||
if ( !tmpFiles.isEmpty() )
|
if ( !tmpFiles.isEmpty() )
|
||||||
{
|
{
|
||||||
StringBuffer emsg = new StringBuffer();
|
StringBuffer emsg = new StringBuffer();
|
||||||
|
@ -419,8 +406,8 @@ public abstract class AbstractProxyTestCase
|
||||||
repo.setLocation( path );
|
repo.setLocation( path );
|
||||||
repo.setLayout( layout );
|
repo.setLayout( layout );
|
||||||
|
|
||||||
ManagedRepositoryContent repoContent =
|
ManagedRepositoryContent repoContent = applicationContext.getBean( "managedRepositoryContent#" + layout,
|
||||||
applicationContext.getBean( "managedRepositoryContent#" + layout, ManagedRepositoryContent.class );
|
ManagedRepositoryContent.class );
|
||||||
repoContent.setRepository( repo );
|
repoContent.setRepository( repo );
|
||||||
return repoContent;
|
return repoContent;
|
||||||
}
|
}
|
||||||
|
@ -502,10 +489,10 @@ public abstract class AbstractProxyTestCase
|
||||||
config.triggerChange( prefix + ".policies.checksum", connectorConfig.getPolicy( "checksum", "" ) );
|
config.triggerChange( prefix + ".policies.checksum", connectorConfig.getPolicy( "checksum", "" ) );
|
||||||
config.triggerChange( prefix + ".policies.snapshots", connectorConfig.getPolicy( "snapshots", "" ) );
|
config.triggerChange( prefix + ".policies.snapshots", connectorConfig.getPolicy( "snapshots", "" ) );
|
||||||
config.triggerChange( prefix + ".policies.cache-failures", connectorConfig.getPolicy( "cache-failures", "" ) );
|
config.triggerChange( prefix + ".policies.cache-failures", connectorConfig.getPolicy( "cache-failures", "" ) );
|
||||||
config.triggerChange( prefix + ".policies.propagate-errors",
|
config.triggerChange( prefix + ".policies.propagate-errors", connectorConfig.getPolicy( "propagate-errors",
|
||||||
connectorConfig.getPolicy( "propagate-errors", "" ) );
|
"" ) );
|
||||||
config.triggerChange( prefix + ".policies.propagate-errors-on-update",
|
config.triggerChange( prefix + ".policies.propagate-errors-on-update", connectorConfig.getPolicy(
|
||||||
connectorConfig.getPolicy( "propagate-errors-on-update", "" ) );
|
"propagate-errors-on-update", "" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void saveManagedRepositoryConfig( String id, String name, String path, String layout )
|
protected void saveManagedRepositoryConfig( String id, String name, String path, String layout )
|
||||||
|
@ -616,7 +603,7 @@ public abstract class AbstractProxyTestCase
|
||||||
|
|
||||||
protected void setManagedNewerThanRemote( File managedFile, File remoteFile )
|
protected void setManagedNewerThanRemote( File managedFile, File remoteFile )
|
||||||
{
|
{
|
||||||
setManagedNewerThanRemote(managedFile, remoteFile, 55000);
|
setManagedNewerThanRemote( managedFile, remoteFile, 55000 );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setManagedNewerThanRemote( File managedFile, File remoteFile, long time )
|
protected void setManagedNewerThanRemote( File managedFile, File remoteFile, long time )
|
||||||
|
@ -631,7 +618,7 @@ public abstract class AbstractProxyTestCase
|
||||||
|
|
||||||
protected void setManagedOlderThanRemote( File managedFile, File remoteFile )
|
protected void setManagedOlderThanRemote( File managedFile, File remoteFile )
|
||||||
{
|
{
|
||||||
setManagedOlderThanRemote(managedFile, remoteFile, 55000 );
|
setManagedOlderThanRemote( managedFile, remoteFile, 55000 );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setManagedOlderThanRemote( File managedFile, File remoteFile, long time )
|
protected void setManagedOlderThanRemote( File managedFile, File remoteFile, long time )
|
||||||
|
@ -657,9 +644,9 @@ public abstract class AbstractProxyTestCase
|
||||||
String managedLegacyPath = managedLegacyDir.getCanonicalPath();
|
String managedLegacyPath = managedLegacyDir.getCanonicalPath();
|
||||||
String testFile = file.getCanonicalPath();
|
String testFile = file.getCanonicalPath();
|
||||||
|
|
||||||
assertTrue(
|
assertTrue( "Unit Test Failure: File <" + testFile +
|
||||||
"Unit Test Failure: File <" + testFile + "> should be have been defined within the legacy managed path of <"
|
"> should be have been defined within the legacy managed path of <" + managedLegacyPath + ">",
|
||||||
+ managedLegacyPath + ">", testFile.startsWith( managedLegacyPath ) );
|
testFile.startsWith( managedLegacyPath ) );
|
||||||
|
|
||||||
assertFalse( "File < " + testFile + "> should not exist in managed legacy repository.", file.exists() );
|
assertFalse( "File < " + testFile + "> should not exist in managed legacy repository.", file.exists() );
|
||||||
}
|
}
|
||||||
|
@ -670,9 +657,9 @@ public abstract class AbstractProxyTestCase
|
||||||
String managedDefaultPath = managedDefaultDir.getCanonicalPath();
|
String managedDefaultPath = managedDefaultDir.getCanonicalPath();
|
||||||
String testFile = file.getCanonicalPath();
|
String testFile = file.getCanonicalPath();
|
||||||
|
|
||||||
assertTrue( "Unit Test Failure: File <" + testFile
|
assertTrue( "Unit Test Failure: File <" + testFile +
|
||||||
+ "> should be have been defined within the managed default path of <" + managedDefaultPath
|
"> should be have been defined within the managed default path of <" + managedDefaultPath + ">",
|
||||||
+ ">", testFile.startsWith( managedDefaultPath ) );
|
testFile.startsWith( managedDefaultPath ) );
|
||||||
|
|
||||||
assertFalse( "File < " + testFile + "> should not exist in managed default repository.", file.exists() );
|
assertFalse( "File < " + testFile + "> should not exist in managed default repository.", file.exists() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,11 @@ import org.apache.maven.archiva.policies.urlcache.UrlFailureCache;
|
||||||
import org.apache.maven.wagon.ResourceDoesNotExistException;
|
import org.apache.maven.wagon.ResourceDoesNotExistException;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CacheFailuresTransferTest
|
* CacheFailuresTransferTest
|
||||||
|
|
|
@ -30,6 +30,9 @@ import org.junit.Test;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ChecksumTransferTest
|
* ChecksumTransferTest
|
||||||
*
|
*
|
||||||
|
@ -57,7 +60,7 @@ public class ChecksumTransferTest
|
||||||
|
|
||||||
File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
|
File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
|
||||||
|
|
||||||
assertNull(downloadedFile);
|
assertNull( downloadedFile );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -430,16 +433,16 @@ public class ChecksumTransferTest
|
||||||
|
|
||||||
// Configure Connector (usually done within archiva.xml configuration)
|
// Configure Connector (usually done within archiva.xml configuration)
|
||||||
saveConnector( ID_DEFAULT_MANAGED, "badproxied", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
|
saveConnector( ID_DEFAULT_MANAGED, "badproxied", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
|
||||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||||
|
|
||||||
wagonMock.get( path, new File( expectedFile.getAbsolutePath() + ".tmp" ) );
|
wagonMock.get( path, new File( expectedFile.getAbsolutePath() + ".tmp" ) );
|
||||||
wagonMockControl.setMatcher(customWagonGetMatcher);
|
wagonMockControl.setMatcher( customWagonGetMatcher );
|
||||||
wagonMockControl.setVoidCallable();
|
wagonMockControl.setVoidCallable();
|
||||||
wagonMock.get( path + ".sha1", new File( expectedFile.getAbsolutePath() + ".sha1.tmp" ) );
|
wagonMock.get( path + ".sha1", new File( expectedFile.getAbsolutePath() + ".sha1.tmp" ) );
|
||||||
wagonMockControl.setMatcher(customWagonGetMatcher);
|
wagonMockControl.setMatcher( customWagonGetMatcher );
|
||||||
wagonMockControl.setVoidCallable();
|
wagonMockControl.setVoidCallable();
|
||||||
wagonMock.get( path + ".md5", new File( expectedFile.getAbsolutePath() + ".md5.tmp" ) );
|
wagonMock.get( path + ".md5", new File( expectedFile.getAbsolutePath() + ".md5.tmp" ) );
|
||||||
wagonMockControl.setMatcher(customWagonGetMatcher);
|
wagonMockControl.setMatcher( customWagonGetMatcher );
|
||||||
wagonMockControl.setThrowable( new ResourceDoesNotExistException( "Resource does not exist." ) );
|
wagonMockControl.setThrowable( new ResourceDoesNotExistException( "Resource does not exist." ) );
|
||||||
wagonMockControl.replay();
|
wagonMockControl.replay();
|
||||||
|
|
||||||
|
@ -477,7 +480,7 @@ public class ChecksumTransferTest
|
||||||
|
|
||||||
// Configure Connector (usually done within archiva.xml configuration)
|
// Configure Connector (usually done within archiva.xml configuration)
|
||||||
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
|
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
|
||||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO , false );
|
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||||
|
|
||||||
File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
|
File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
|
||||||
|
|
||||||
|
@ -504,7 +507,7 @@ public class ChecksumTransferTest
|
||||||
|
|
||||||
// Configure Connector (usually done within archiva.xml configuration)
|
// Configure Connector (usually done within archiva.xml configuration)
|
||||||
saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, ChecksumPolicy.FAIL, ReleasesPolicy.ALWAYS,
|
saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, ChecksumPolicy.FAIL, ReleasesPolicy.ALWAYS,
|
||||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO , false );
|
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||||
|
|
||||||
File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
|
File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
|
||||||
|
|
||||||
|
@ -532,7 +535,7 @@ public class ChecksumTransferTest
|
||||||
|
|
||||||
// Configure Connector (usually done within archiva.xml configuration)
|
// Configure Connector (usually done within archiva.xml configuration)
|
||||||
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
|
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
|
||||||
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO , false );
|
SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false );
|
||||||
|
|
||||||
File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
|
File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,8 @@ import org.junit.Test;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ErrorHandlingTest
|
* ErrorHandlingTest
|
||||||
*
|
*
|
||||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.maven.archiva.proxy;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||||
|
@ -53,15 +52,16 @@ import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integration test for connecting over a HTTP proxy.
|
* Integration test for connecting over a HTTP proxy.
|
||||||
*
|
*
|
||||||
* @version $Id: ManagedDefaultTransferTest.java 677852 2008-07-18 08:16:24Z brett $
|
* @version $Id: ManagedDefaultTransferTest.java 677852 2008-07-18 08:16:24Z brett $
|
||||||
*/
|
*/
|
||||||
@RunWith( SpringJUnit4ClassRunner.class )
|
@RunWith( SpringJUnit4ClassRunner.class )
|
||||||
@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } )
|
@ContextConfiguration( locations = {"classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml"} )
|
||||||
public class HttpProxyTransferTest
|
public class HttpProxyTransferTest
|
||||||
extends TestCase
|
|
||||||
{
|
{
|
||||||
private static final String PROXY_ID = "proxy";
|
private static final String PROXY_ID = "proxy";
|
||||||
|
|
||||||
|
@ -86,8 +86,6 @@ public class HttpProxyTransferTest
|
||||||
public void setUp()
|
public void setUp()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
super.setUp();
|
|
||||||
|
|
||||||
proxyHandler = applicationContext.getBean( "repositoryProxyConnectors#test", RepositoryProxyConnectors.class );
|
proxyHandler = applicationContext.getBean( "repositoryProxyConnectors#test", RepositoryProxyConnectors.class );
|
||||||
|
|
||||||
config = applicationContext.getBean( "archivaConfiguration#mock", ArchivaConfiguration.class );
|
config = applicationContext.getBean( "archivaConfiguration#mock", ArchivaConfiguration.class );
|
||||||
|
@ -97,7 +95,7 @@ public class HttpProxyTransferTest
|
||||||
config.getConfiguration().getProxyConnectors().clear();
|
config.getConfiguration().getProxyConnectors().clear();
|
||||||
|
|
||||||
// Setup source repository (using default layout)
|
// Setup source repository (using default layout)
|
||||||
String repoPath = "target/test-repository/managed/" + getName();
|
String repoPath = "target/test-repository/managed/" + getClass().getSimpleName();
|
||||||
|
|
||||||
File destRepoDir = new File( repoPath );
|
File destRepoDir = new File( repoPath );
|
||||||
|
|
||||||
|
@ -116,8 +114,8 @@ public class HttpProxyTransferTest
|
||||||
repo.setLocation( repoPath );
|
repo.setLocation( repoPath );
|
||||||
repo.setLayout( "default" );
|
repo.setLayout( "default" );
|
||||||
|
|
||||||
ManagedRepositoryContent repoContent =
|
ManagedRepositoryContent repoContent = applicationContext.getBean( "managedRepositoryContent#default",
|
||||||
applicationContext.getBean( "managedRepositoryContent#default", ManagedRepositoryContent.class );
|
ManagedRepositoryContent.class );
|
||||||
|
|
||||||
repoContent.setRepository( repo );
|
repoContent.setRepository( repo );
|
||||||
managedDefaultRepository = repoContent;
|
managedDefaultRepository = repoContent;
|
||||||
|
@ -167,8 +165,6 @@ public class HttpProxyTransferTest
|
||||||
public void tearDown()
|
public void tearDown()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
super.tearDown();
|
|
||||||
|
|
||||||
server.stop();
|
server.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,8 @@ import org.junit.Test;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ManagedDefaultTransferTest
|
* ManagedDefaultTransferTest
|
||||||
*
|
*
|
||||||
|
|
|
@ -28,6 +28,8 @@ import org.junit.Test;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ManagedLegacyTransferTest
|
* ManagedLegacyTransferTest
|
||||||
*
|
*
|
||||||
|
|
|
@ -41,12 +41,14 @@ import org.custommonkey.xmlunit.Diff;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Named;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MetadataTransferTest - Tests the various fetching / merging concepts surrounding the maven-metadata.xml files
|
* MetadataTransferTest - Tests the various fetching / merging concepts surrounding the maven-metadata.xml files
|
||||||
|
|
|
@ -28,6 +28,9 @@ import org.junit.Test;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SnapshotTransferTest
|
* SnapshotTransferTest
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue