From: Olivier Lamy Date: Mon, 13 Jun 2011 20:33:20 +0000 (+0000) Subject: fix junit : ensure file from previous test is deleted, cleanup connectors before... X-Git-Tag: archiva-1.4-M1~657 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e318df26fc4d71c90dc0f30c2f824c7110e85a22;p=archiva.git fix junit : ensure file from previous test is deleted, cleanup connectors before/after each tests git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1135264 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletProxiedTestCase.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletProxiedTestCase.java index 98d7f10d9..9978e62cf 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletProxiedTestCase.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletProxiedTestCase.java @@ -195,6 +195,10 @@ public abstract class AbstractRepositoryServletProxiedTestCase throws Exception { File destFile = new File( remoteRepo.root, path ); + if (destFile.exists()) + { + destFile.delete(); + } destFile.getParentFile().mkdirs(); FileUtils.writeStringToFile( destFile, contents, null ); return destFile; diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletProxiedTimestampedSnapshotPolicyTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletProxiedTimestampedSnapshotPolicyTest.java index d03b16d68..250e17b7a 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletProxiedTimestampedSnapshotPolicyTest.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletProxiedTimestampedSnapshotPolicyTest.java @@ -23,16 +23,17 @@ import com.meterware.httpunit.GetMethodWebRequest; import com.meterware.httpunit.HttpUnitOptions; import com.meterware.httpunit.WebRequest; import com.meterware.httpunit.WebResponse; - +import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration; import org.apache.maven.archiva.policies.SnapshotsPolicy; import org.junit.After; import org.junit.Before; import org.junit.Test; import java.io.File; +import java.util.ArrayList; /** - * RepositoryServlet Tests, Proxied, Get of Timestamped Snapshot Artifacts, with varying policy settings. + * RepositoryServlet Tests, Proxied, Get of Timestamped Snapshot Artifacts, with varying policy settings. * * @version $Id$ */ @@ -44,6 +45,7 @@ public class RepositoryServletProxiedTimestampedSnapshotPolicyTest public void setup() throws Exception { + archivaConfiguration.getConfiguration().setProxyConnectors( new ArrayList() ); super.setUp(); } @@ -51,6 +53,8 @@ public class RepositoryServletProxiedTimestampedSnapshotPolicyTest public void tearDown() throws Exception { + archivaConfiguration.getConfiguration().setProxyConnectors( new ArrayList() ); + super.tearDown(); } @@ -58,8 +62,8 @@ public class RepositoryServletProxiedTimestampedSnapshotPolicyTest public void testGetProxiedSnapshotsArtifactPolicyAlwaysManagedNewer() throws Exception { - assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.ALWAYS, - HAS_MANAGED_COPY, ( NEWER * OVER_ONE_DAY ) ); + assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.ALWAYS, HAS_MANAGED_COPY, + ( NEWER * OVER_ONE_DAY ) ); } @Test @@ -104,8 +108,7 @@ public class RepositoryServletProxiedTimestampedSnapshotPolicyTest public void testGetProxiedSnapshotsArtifactPolicyRejectFail() throws Exception { - assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.NEVER, - HAS_MANAGED_COPY ); + assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.NEVER, HAS_MANAGED_COPY ); } @Test @@ -119,8 +122,7 @@ public class RepositoryServletProxiedTimestampedSnapshotPolicyTest public void testGetProxiedSnapshotsArtifactPolicyRejectPass() throws Exception { - assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.NEVER, - HAS_MANAGED_COPY ); + assertGetProxiedSnapshotsArtifactWithPolicy( EXPECT_MANAGED_CONTENTS, SnapshotsPolicy.NEVER, HAS_MANAGED_COPY ); } @Test @@ -175,7 +177,8 @@ public class RepositoryServletProxiedTimestampedSnapshotPolicyTest } private void assertGetProxiedSnapshotsArtifactWithPolicy( int expectation, String snapshotsPolicy, - boolean hasManagedCopy, long deltaManagedToRemoteTimestamp ) + boolean hasManagedCopy, + long deltaManagedToRemoteTimestamp ) throws Exception { // --- Setup @@ -211,7 +214,7 @@ public class RepositoryServletProxiedTimestampedSnapshotPolicyTest case EXPECT_MANAGED_CONTENTS: assertResponseOK( response ); assertTrue( "Invalid Test Case: Can't expect managed contents with " - + "test that doesn't have a managed copy in the first place.", hasManagedCopy ); + + "test that doesn't have a managed copy in the first place.", hasManagedCopy ); assertEquals( "Expected managed file contents", expectedManagedContents, response.getText() ); break; case EXPECT_REMOTE_CONTENTS: