From 8a0900d6caa331fb4f6a7ba2317c1efbae4e7d7a Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Thu, 4 Oct 2012 11:47:00 -0700 Subject: [PATCH] Prefer fail over assertTrue(false) where possible --- .../jclouds/cache/RetryingCacheLoaderDecoratorTest.java | 6 +++--- ...ffExponentiallyAndRetryOnThrowableCacheLoaderTest.java | 6 +++--- ...ckoffExponentiallyAndRetryOnThrowableCallableTest.java | 4 ++-- core/src/test/java/org/jclouds/internal/BaseViewTest.java | 4 ++-- .../rimuhosting/miro/RimuHostingClientLiveTest.java | 8 +++----- 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/core/src/test/java/org/jclouds/cache/RetryingCacheLoaderDecoratorTest.java b/core/src/test/java/org/jclouds/cache/RetryingCacheLoaderDecoratorTest.java index 38c52aa7a8..4325dacb05 100644 --- a/core/src/test/java/org/jclouds/cache/RetryingCacheLoaderDecoratorTest.java +++ b/core/src/test/java/org/jclouds/cache/RetryingCacheLoaderDecoratorTest.java @@ -24,7 +24,7 @@ import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; import org.jclouds.rest.ResourceNotFoundException; import org.testng.annotations.BeforeMethod; @@ -76,10 +76,10 @@ public class RetryingCacheLoaderDecoratorTest { replay(mock); try { backoff.load("foo"); - assertTrue(false); + fail(); } catch (ResourceNotFoundException e) { } verify(mock); } -} \ No newline at end of file +} diff --git a/core/src/test/java/org/jclouds/cache/internal/BackoffExponentiallyAndRetryOnThrowableCacheLoaderTest.java b/core/src/test/java/org/jclouds/cache/internal/BackoffExponentiallyAndRetryOnThrowableCacheLoaderTest.java index 01c7628989..c47314b3fe 100644 --- a/core/src/test/java/org/jclouds/cache/internal/BackoffExponentiallyAndRetryOnThrowableCacheLoaderTest.java +++ b/core/src/test/java/org/jclouds/cache/internal/BackoffExponentiallyAndRetryOnThrowableCacheLoaderTest.java @@ -23,7 +23,7 @@ import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; @@ -70,7 +70,7 @@ public class BackoffExponentiallyAndRetryOnThrowableCacheLoaderTest { replay(mock); try { backoff.load("foo"); - assertTrue(false); + fail(); } catch (ResourceNotFoundException e) { } @@ -88,7 +88,7 @@ public class BackoffExponentiallyAndRetryOnThrowableCacheLoaderTest { replay(mock); try { backoff.load("foo"); - assertTrue(false); + fail(); } catch (TimeoutException e) { } diff --git a/core/src/test/java/org/jclouds/cache/internal/BackoffExponentiallyAndRetryOnThrowableCallableTest.java b/core/src/test/java/org/jclouds/cache/internal/BackoffExponentiallyAndRetryOnThrowableCallableTest.java index 4e370a6109..a206d52a89 100644 --- a/core/src/test/java/org/jclouds/cache/internal/BackoffExponentiallyAndRetryOnThrowableCallableTest.java +++ b/core/src/test/java/org/jclouds/cache/internal/BackoffExponentiallyAndRetryOnThrowableCallableTest.java @@ -23,7 +23,7 @@ import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; import java.util.concurrent.Callable; @@ -66,7 +66,7 @@ public class BackoffExponentiallyAndRetryOnThrowableCallableTest { replay(mock); try { backoff.call(); - assertTrue(false); + fail(); } catch (ResourceNotFoundException e) { } diff --git a/core/src/test/java/org/jclouds/internal/BaseViewTest.java b/core/src/test/java/org/jclouds/internal/BaseViewTest.java index 4c89f9ec0a..8dc4488628 100644 --- a/core/src/test/java/org/jclouds/internal/BaseViewTest.java +++ b/core/src/test/java/org/jclouds/internal/BaseViewTest.java @@ -21,8 +21,8 @@ package org.jclouds.internal; import static org.easymock.EasyMock.createMock; import static org.easymock.EasyMock.expect; import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotEquals; +import static org.testng.Assert.fail; import org.jclouds.lifecycle.Closer; import org.jclouds.providers.ProviderMetadata; @@ -89,7 +89,7 @@ public class BaseViewTest { assertNotEquals(wine.getBackendType(), TypeToken.of(PeanutButter.class)); try { wine.unwrap(TypeToken.of(PeanutButter.class)); - assertFalse(true); + fail(); } catch (IllegalArgumentException e) { assertEquals(e.getMessage(), "backend type: org.jclouds.internal.BaseViewTest$Water not assignable from org.jclouds.internal.BaseViewTest$PeanutButter"); } diff --git a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingClientLiveTest.java b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingClientLiveTest.java index 388cabd63a..f54d2acedf 100644 --- a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingClientLiveTest.java +++ b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingClientLiveTest.java @@ -20,7 +20,7 @@ package org.jclouds.rimuhosting.miro; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; import java.util.Set; @@ -66,11 +66,10 @@ public class RimuHostingClientLiveTest Set plans = connection.getPricingPlanList(); for (PricingPlan plan : plans) { if (plan.getId().equalsIgnoreCase("MIRO4B")) { - assertTrue(true); return; } } - assertTrue(false); + fail("MIRO4B not found"); } @Test @@ -78,11 +77,10 @@ public class RimuHostingClientLiveTest Set images = connection.getImageList(); for (Image image : images) { if (image.getId().equalsIgnoreCase("lenny")) { - assertTrue(true); return; } } - assertTrue(false, "lenny not found"); + fail("lenny not found"); } @Test