diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/AbstractProxyTestCase.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/AbstractProxyTestCase.java index 574358476..fc6ed6a24 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/AbstractProxyTestCase.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/AbstractProxyTestCase.java @@ -19,11 +19,9 @@ package org.apache.maven.archiva.proxy; * under the License. */ -import junit.framework.TestCase; import net.sf.ehcache.CacheManager; import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; 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.ManagedRepositoryConfiguration; 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.junit4.SpringJUnit4ClassRunner; -import javax.inject.Inject; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; @@ -59,6 +56,9 @@ import java.util.Calendar; import java.util.Collection; import java.util.Date; import java.util.Locale; +import javax.inject.Inject; + +import static org.junit.Assert.*; /** * AbstractProxyTestCase @@ -66,11 +66,9 @@ import java.util.Locale; * @version $Id$ */ @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 - extends TestCase { - @Inject protected ApplicationContext applicationContext; @@ -134,21 +132,20 @@ public abstract class AbstractProxyTestCase public void setUp() 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() ); config.getConfiguration().setRemoteRepositories( new ArrayList() ); config.getConfiguration().setProxyConnectors( new ArrayList() ); // 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 ); - managedDefaultRepository = - createRepository( ID_DEFAULT_MANAGED, "Default Managed Repository", repoPath, "default" ); + managedDefaultRepository = createRepository( ID_DEFAULT_MANAGED, "Default Managed Repository", repoPath, + "default" ); managedDefaultDir = new File( managedDefaultRepository.getRepoRoot() ); @@ -158,17 +155,14 @@ public abstract class AbstractProxyTestCase // Setup source repository (using legacy layout) repoLocation = new File( REPOPATH_LEGACY_MANAGED_TARGET ); - if (repoLocation.exists()) + if ( repoLocation.exists() ) { FileUtils.deleteDirectory( repoLocation ); } copyDirectoryStructure( new File( REPOPATH_LEGACY_MANAGED ), repoLocation ); - managedLegacyRepository = - createRepository( ID_LEGACY_MANAGED, "Legacy Managed Repository", REPOPATH_LEGACY_MANAGED_TARGET, - "legacy" ); - - + managedLegacyRepository = createRepository( ID_LEGACY_MANAGED, "Legacy Managed Repository", + REPOPATH_LEGACY_MANAGED_TARGET, "legacy" ); managedLegacyDir = new File( managedLegacyRepository.getRepoRoot() ); @@ -177,22 +171,21 @@ public abstract class AbstractProxyTestCase config.getConfiguration().addManagedRepository( repoConfig ); // Setup target (proxied to) repository. - saveRemoteRepositoryConfig( ID_PROXIED1, "Proxied Repository 1", - new File( REPOPATH_PROXIED1 ).toURL().toExternalForm(), "default" ); + saveRemoteRepositoryConfig( ID_PROXIED1, "Proxied Repository 1", new File( + REPOPATH_PROXIED1 ).toURL().toExternalForm(), "default" ); // Setup target (proxied to) repository. - saveRemoteRepositoryConfig( ID_PROXIED2, "Proxied Repository 2", - new File( REPOPATH_PROXIED2 ).toURL().toExternalForm(), "default" ); + saveRemoteRepositoryConfig( ID_PROXIED2, "Proxied Repository 2", new File( + REPOPATH_PROXIED2 ).toURL().toExternalForm(), "default" ); // Setup target (proxied to) repository using legacy layout. - saveRemoteRepositoryConfig( ID_LEGACY_PROXIED, "Proxied Legacy Repository", - new File( REPOPATH_PROXIED_LEGACY ).toURL().toExternalForm(), "legacy" ); + saveRemoteRepositoryConfig( ID_LEGACY_PROXIED, "Proxied Legacy Repository", new File( + REPOPATH_PROXIED_LEGACY ).toURL().toExternalForm(), "legacy" ); // Setup the proxy handler. //proxyHandler = applicationContext.getBean (RepositoryProxyConnectors) lookup( RepositoryProxyConnectors.class.getName() ); - proxyHandler = - applicationContext.getBean( "repositoryProxyConnectors#test", RepositoryProxyConnectors.class ); + proxyHandler = applicationContext.getBean( "repositoryProxyConnectors#test", RepositoryProxyConnectors.class ); // Setup the wagon mock. wagonMockControl = MockControl.createNiceControl( Wagon.class ); @@ -204,13 +197,7 @@ public abstract class AbstractProxyTestCase CacheManager.getInstance().clearAll(); - log.info( "\n.\\ " + getName() + "() \\._________________________________________\n" ); - } - - @Override - public String getName() - { - return StringUtils.substringAfterLast( getClass().getName(), "." ); + log.info( "\n.\\ " + name + "() \\._________________________________________\n" ); } protected static final ArgumentsMatcher customWagonGetIfNewerMatcher = new ArgumentsMatcher() @@ -222,8 +209,8 @@ public abstract class AbstractProxyTestCase { return false; } - return MockControl.ARRAY_MATCHER.matches( ArrayUtils.remove( expected, 1 ), - ArrayUtils.remove( actual, 1 ) ); + return MockControl.ARRAY_MATCHER.matches( ArrayUtils.remove( expected, 1 ), ArrayUtils.remove( actual, + 1 ) ); } public String toString( Object[] arguments ) @@ -325,7 +312,7 @@ public abstract class AbstractProxyTestCase return; } - Collection tmpFiles = org.apache.commons.io.FileUtils.listFiles( workingDir, new String[]{ "tmp" }, false ); + Collection tmpFiles = org.apache.commons.io.FileUtils.listFiles( workingDir, new String[]{"tmp"}, false ); if ( !tmpFiles.isEmpty() ) { StringBuffer emsg = new StringBuffer(); @@ -419,8 +406,8 @@ public abstract class AbstractProxyTestCase repo.setLocation( path ); repo.setLayout( layout ); - ManagedRepositoryContent repoContent = - applicationContext.getBean( "managedRepositoryContent#" + layout, ManagedRepositoryContent.class ); + ManagedRepositoryContent repoContent = applicationContext.getBean( "managedRepositoryContent#" + layout, + ManagedRepositoryContent.class ); repoContent.setRepository( repo ); return repoContent; } @@ -502,10 +489,10 @@ public abstract class AbstractProxyTestCase config.triggerChange( prefix + ".policies.checksum", connectorConfig.getPolicy( "checksum", "" ) ); config.triggerChange( prefix + ".policies.snapshots", connectorConfig.getPolicy( "snapshots", "" ) ); config.triggerChange( prefix + ".policies.cache-failures", connectorConfig.getPolicy( "cache-failures", "" ) ); - config.triggerChange( prefix + ".policies.propagate-errors", - connectorConfig.getPolicy( "propagate-errors", "" ) ); - config.triggerChange( prefix + ".policies.propagate-errors-on-update", - connectorConfig.getPolicy( "propagate-errors-on-update", "" ) ); + config.triggerChange( prefix + ".policies.propagate-errors", connectorConfig.getPolicy( "propagate-errors", + "" ) ); + config.triggerChange( prefix + ".policies.propagate-errors-on-update", connectorConfig.getPolicy( + "propagate-errors-on-update", "" ) ); } 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 ) { - setManagedNewerThanRemote(managedFile, remoteFile, 55000); + setManagedNewerThanRemote( managedFile, remoteFile, 55000 ); } protected void setManagedNewerThanRemote( File managedFile, File remoteFile, long time ) @@ -631,7 +618,7 @@ public abstract class AbstractProxyTestCase protected void setManagedOlderThanRemote( File managedFile, File remoteFile ) { - setManagedOlderThanRemote(managedFile, remoteFile, 55000 ); + setManagedOlderThanRemote( managedFile, remoteFile, 55000 ); } protected void setManagedOlderThanRemote( File managedFile, File remoteFile, long time ) @@ -657,9 +644,9 @@ public abstract class AbstractProxyTestCase String managedLegacyPath = managedLegacyDir.getCanonicalPath(); String testFile = file.getCanonicalPath(); - assertTrue( - "Unit Test Failure: File <" + testFile + "> should be have been defined within the legacy managed path of <" - + managedLegacyPath + ">", testFile.startsWith( managedLegacyPath ) ); + assertTrue( "Unit Test Failure: File <" + testFile + + "> should be have been defined within the legacy managed path of <" + managedLegacyPath + ">", + testFile.startsWith( managedLegacyPath ) ); 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 testFile = file.getCanonicalPath(); - assertTrue( "Unit Test Failure: File <" + testFile - + "> should be have been defined within the managed default path of <" + managedDefaultPath - + ">", testFile.startsWith( managedDefaultPath ) ); + assertTrue( "Unit Test Failure: File <" + testFile + + "> should be have been defined within the managed default path of <" + managedDefaultPath + ">", + testFile.startsWith( managedDefaultPath ) ); assertFalse( "File < " + testFile + "> should not exist in managed default repository.", file.exists() ); } diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/CacheFailuresTransferTest.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/CacheFailuresTransferTest.java index fd951e44e..d6ddb995a 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/CacheFailuresTransferTest.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/CacheFailuresTransferTest.java @@ -29,8 +29,11 @@ import org.apache.maven.archiva.policies.urlcache.UrlFailureCache; import org.apache.maven.wagon.ResourceDoesNotExistException; import org.junit.Test; -import javax.inject.Inject; import java.io.File; +import javax.inject.Inject; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; /** * CacheFailuresTransferTest diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ChecksumTransferTest.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ChecksumTransferTest.java index 12554ea3d..8befed7a9 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ChecksumTransferTest.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ChecksumTransferTest.java @@ -30,6 +30,9 @@ import org.junit.Test; import java.io.File; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; + /** * ChecksumTransferTest * @@ -54,10 +57,10 @@ public class ChecksumTransferTest // Configure Connector (usually done within archiva.xml configuration) saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS, SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, true ); - + File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact ); - - assertNull(downloadedFile); + + assertNull( downloadedFile ); } @Test @@ -430,16 +433,16 @@ public class ChecksumTransferTest // Configure Connector (usually done within archiva.xml configuration) 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" ) ); - wagonMockControl.setMatcher(customWagonGetMatcher); + wagonMockControl.setMatcher( customWagonGetMatcher ); wagonMockControl.setVoidCallable(); wagonMock.get( path + ".sha1", new File( expectedFile.getAbsolutePath() + ".sha1.tmp" ) ); - wagonMockControl.setMatcher(customWagonGetMatcher); + wagonMockControl.setMatcher( customWagonGetMatcher ); wagonMockControl.setVoidCallable(); 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.replay(); @@ -470,14 +473,14 @@ public class ChecksumTransferTest File expectedFile = new File( managedDefaultDir, path ); File remoteFile = new File( REPOPATH_PROXIED1, path ); - + setManagedOlderThanRemote( expectedFile, remoteFile ); ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); // Configure Connector (usually done within archiva.xml configuration) 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 ); @@ -499,12 +502,12 @@ public class ChecksumTransferTest File remoteFile = new File( REPOPATH_PROXIED1, path ); setManagedOlderThanRemote( expectedFile, remoteFile ); - + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); // Configure Connector (usually done within archiva.xml configuration) 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 ); @@ -512,7 +515,7 @@ public class ChecksumTransferTest assertNoTempFiles( expectedFile ); // There are no hashcodes on the proxy side to download. // The FAIL policy will delete the checksums as bad. - + assertChecksums( expectedFile, "invalid checksum file", "invalid checksum file" ); } @@ -525,14 +528,14 @@ public class ChecksumTransferTest File expectedFile = new File( managedDefaultDir, path ); File remoteFile = new File( REPOPATH_PROXIED1, path ); - + setManagedOlderThanRemote( expectedFile, remoteFile ); ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); // Configure Connector (usually done within archiva.xml configuration) 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 ); diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ErrorHandlingTest.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ErrorHandlingTest.java index a24e0c32f..fc460532c 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ErrorHandlingTest.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ErrorHandlingTest.java @@ -34,6 +34,8 @@ import org.junit.Test; import java.io.File; +import static org.junit.Assert.*; + /** * ErrorHandlingTest * diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/HttpProxyTransferTest.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/HttpProxyTransferTest.java index 2c236a0c1..32f552965 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/HttpProxyTransferTest.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/HttpProxyTransferTest.java @@ -19,7 +19,6 @@ package org.apache.maven.archiva.proxy; * under the License. */ -import junit.framework.TestCase; import org.apache.commons.io.FileUtils; import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; @@ -53,15 +52,16 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import static org.junit.Assert.*; + /** * Integration test for connecting over a HTTP proxy. * * @version $Id: ManagedDefaultTransferTest.java 677852 2008-07-18 08:16:24Z brett $ */ @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 - extends TestCase { private static final String PROXY_ID = "proxy"; @@ -86,8 +86,6 @@ public class HttpProxyTransferTest public void setUp() throws Exception { - super.setUp(); - proxyHandler = applicationContext.getBean( "repositoryProxyConnectors#test", RepositoryProxyConnectors.class ); config = applicationContext.getBean( "archivaConfiguration#mock", ArchivaConfiguration.class ); @@ -97,7 +95,7 @@ public class HttpProxyTransferTest config.getConfiguration().getProxyConnectors().clear(); // 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 ); @@ -116,8 +114,8 @@ public class HttpProxyTransferTest repo.setLocation( repoPath ); repo.setLayout( "default" ); - ManagedRepositoryContent repoContent = - applicationContext.getBean( "managedRepositoryContent#default", ManagedRepositoryContent.class ); + ManagedRepositoryContent repoContent = applicationContext.getBean( "managedRepositoryContent#default", + ManagedRepositoryContent.class ); repoContent.setRepository( repo ); managedDefaultRepository = repoContent; @@ -167,8 +165,6 @@ public class HttpProxyTransferTest public void tearDown() throws Exception { - super.tearDown(); - server.stop(); } diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ManagedDefaultTransferTest.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ManagedDefaultTransferTest.java index 2a03aa7d3..aabcfb298 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ManagedDefaultTransferTest.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ManagedDefaultTransferTest.java @@ -31,6 +31,8 @@ import org.junit.Test; import java.io.File; +import static org.junit.Assert.*; + /** * ManagedDefaultTransferTest * diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ManagedLegacyTransferTest.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ManagedLegacyTransferTest.java index 7fcb198e6..a100d1282 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ManagedLegacyTransferTest.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/ManagedLegacyTransferTest.java @@ -28,6 +28,8 @@ import org.junit.Test; import java.io.File; +import static org.junit.Assert.assertTrue; + /** * ManagedLegacyTransferTest * diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/MetadataTransferTest.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/MetadataTransferTest.java index d0166d1e8..e021d96b2 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/MetadataTransferTest.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/MetadataTransferTest.java @@ -41,12 +41,14 @@ import org.custommonkey.xmlunit.Diff; import org.junit.Before; import org.junit.Test; -import javax.inject.Inject; -import javax.inject.Named; import java.io.File; import java.io.StringWriter; import java.util.ArrayList; 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 diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/SnapshotTransferTest.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/SnapshotTransferTest.java index f1998971d..a9ed4a122 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/SnapshotTransferTest.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/SnapshotTransferTest.java @@ -28,6 +28,9 @@ import org.junit.Test; import java.io.File; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + /** * SnapshotTransferTest *