From cec029944437f35795b652e364fa9a9334e4c9ef Mon Sep 17 00:00:00 2001 From: skygo Date: Mon, 6 Aug 2012 22:17:09 +0000 Subject: [PATCH] testPolicyYes rerunnable +@Override in test classes git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1370044 13f79535-47bb-0310-9956-ffa450edef68 --- .../policies/CachedFailuresPolicyTest.java | 21 +++++++------------ .../archiva/policies/ReleasePolicyTest.java | 1 + 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/archiva-modules/archiva-base/archiva-policies/src/test/java/org/apache/archiva/policies/CachedFailuresPolicyTest.java b/archiva-modules/archiva-base/archiva-policies/src/test/java/org/apache/archiva/policies/CachedFailuresPolicyTest.java index 4cae2df12..6f46b6845 100644 --- a/archiva-modules/archiva-base/archiva-policies/src/test/java/org/apache/archiva/policies/CachedFailuresPolicyTest.java +++ b/archiva-modules/archiva-base/archiva-policies/src/test/java/org/apache/archiva/policies/CachedFailuresPolicyTest.java @@ -81,7 +81,7 @@ public class CachedFailuresPolicyTest policy.applyPolicy( CachedFailuresPolicy.NO, request, localFile ); } - @Test + @Test( expected = PolicyViolationException.class ) public void testPolicyYes() throws Exception { @@ -89,28 +89,21 @@ public class CachedFailuresPolicyTest DownloadPolicy policy = lookupPolicy(); File localFile = getFile(); Properties request = createRequest(); - - request.setProperty( "url", "http://a.bad.hostname.maven.org/path/to/resource.txt" ); + // make unique name + String url = "http://a.bad.hostname.maven.org/path/to/resource"+ System.currentTimeMillis() +".txt"; + + request.setProperty( "url", url ); // should not fail policy.applyPolicy( CachedFailuresPolicy.YES, request, localFile ); // status Yes Not In cache // Yes in Cache - String url = "http://a.bad.hostname.maven.org/path/to/resource.txt"; - + urlFailureCache.cacheFailure( url ); request.setProperty( "url", url ); - try - { - policy.applyPolicy( CachedFailuresPolicy.YES, request, localFile ); - fail( "Expected a PolicyViolationException." ); - } - catch ( PolicyViolationException e ) - { - // expected path. - } + policy.applyPolicy( CachedFailuresPolicy.YES, request, localFile ); } } diff --git a/archiva-modules/archiva-base/archiva-policies/src/test/java/org/apache/archiva/policies/ReleasePolicyTest.java b/archiva-modules/archiva-base/archiva-policies/src/test/java/org/apache/archiva/policies/ReleasePolicyTest.java index f2babbb77..2a02605d0 100644 --- a/archiva-modules/archiva-base/archiva-policies/src/test/java/org/apache/archiva/policies/ReleasePolicyTest.java +++ b/archiva-modules/archiva-base/archiva-policies/src/test/java/org/apache/archiva/policies/ReleasePolicyTest.java @@ -368,6 +368,7 @@ public class ReleasePolicyTest @Before + @Override public void setUp() throws Exception {