Merge pull request #880 from andrewgaul/fail

Prefer fail over assertTrue(false) where possible
This commit is contained in:
Adrian Cole 2012-10-07 13:19:18 -07:00
commit 79f0361e4a
5 changed files with 13 additions and 15 deletions

View File

@ -24,7 +24,7 @@ import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify; import static org.easymock.EasyMock.verify;
import static org.testng.Assert.assertSame; 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.jclouds.rest.ResourceNotFoundException;
import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeMethod;
@ -76,10 +76,10 @@ public class RetryingCacheLoaderDecoratorTest {
replay(mock); replay(mock);
try { try {
backoff.load("foo"); backoff.load("foo");
assertTrue(false); fail();
} catch (ResourceNotFoundException e) { } catch (ResourceNotFoundException e) {
} }
verify(mock); verify(mock);
} }
} }

View File

@ -23,7 +23,7 @@ import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify; import static org.easymock.EasyMock.verify;
import static org.testng.Assert.assertSame; 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.ExecutionException;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
@ -70,7 +70,7 @@ public class BackoffExponentiallyAndRetryOnThrowableCacheLoaderTest {
replay(mock); replay(mock);
try { try {
backoff.load("foo"); backoff.load("foo");
assertTrue(false); fail();
} catch (ResourceNotFoundException e) { } catch (ResourceNotFoundException e) {
} }
@ -88,7 +88,7 @@ public class BackoffExponentiallyAndRetryOnThrowableCacheLoaderTest {
replay(mock); replay(mock);
try { try {
backoff.load("foo"); backoff.load("foo");
assertTrue(false); fail();
} catch (TimeoutException e) { } catch (TimeoutException e) {
} }

View File

@ -23,7 +23,7 @@ import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify; import static org.easymock.EasyMock.verify;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
@ -66,7 +66,7 @@ public class BackoffExponentiallyAndRetryOnThrowableCallableTest {
replay(mock); replay(mock);
try { try {
backoff.call(); backoff.call();
assertTrue(false); fail();
} catch (ResourceNotFoundException e) { } catch (ResourceNotFoundException e) {
} }

View File

@ -21,8 +21,8 @@ package org.jclouds.internal;
import static org.easymock.EasyMock.createMock; import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.expect;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotEquals; import static org.testng.Assert.assertNotEquals;
import static org.testng.Assert.fail;
import org.jclouds.lifecycle.Closer; import org.jclouds.lifecycle.Closer;
import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.ProviderMetadata;
@ -89,7 +89,7 @@ public class BaseViewTest {
assertNotEquals(wine.getBackendType(), TypeToken.of(PeanutButter.class)); assertNotEquals(wine.getBackendType(), TypeToken.of(PeanutButter.class));
try { try {
wine.unwrap(TypeToken.of(PeanutButter.class)); wine.unwrap(TypeToken.of(PeanutButter.class));
assertFalse(true); fail();
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
assertEquals(e.getMessage(), "backend type: org.jclouds.internal.BaseViewTest$Water not assignable from org.jclouds.internal.BaseViewTest$PeanutButter"); assertEquals(e.getMessage(), "backend type: org.jclouds.internal.BaseViewTest$Water not assignable from org.jclouds.internal.BaseViewTest$PeanutButter");
} }

View File

@ -20,7 +20,7 @@ package org.jclouds.rimuhosting.miro;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail;
import java.util.Set; import java.util.Set;
@ -66,11 +66,10 @@ public class RimuHostingClientLiveTest
Set<? extends PricingPlan> plans = connection.getPricingPlanList(); Set<? extends PricingPlan> plans = connection.getPricingPlanList();
for (PricingPlan plan : plans) { for (PricingPlan plan : plans) {
if (plan.getId().equalsIgnoreCase("MIRO4B")) { if (plan.getId().equalsIgnoreCase("MIRO4B")) {
assertTrue(true);
return; return;
} }
} }
assertTrue(false); fail("MIRO4B not found");
} }
@Test @Test
@ -78,11 +77,10 @@ public class RimuHostingClientLiveTest
Set<? extends Image> images = connection.getImageList(); Set<? extends Image> images = connection.getImageList();
for (Image image : images) { for (Image image : images) {
if (image.getId().equalsIgnoreCase("lenny")) { if (image.getId().equalsIgnoreCase("lenny")) {
assertTrue(true);
return; return;
} }
} }
assertTrue(false, "lenny not found"); fail("lenny not found");
} }
@Test @Test