Prefer Assert.fail over assert

The former cannot be disabled.
This commit is contained in:
Andrew Gaul 2012-11-03 14:50:54 -07:00
parent 10ab929097
commit 0761874578
30 changed files with 89 additions and 59 deletions

View File

@ -19,6 +19,7 @@
package org.jclouds.atmos;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.fail;
import java.io.IOException;
import java.lang.reflect.UndeclaredThrowableException;
@ -272,7 +273,7 @@ public class AtmosClientLiveTest extends BaseBlobStoreIntegrationTest {
Strings2.toStringAndClose(URI.create(
"http://accesspoint.emccis.com/rest/objects/" + getBlob.getSystemMetadata().getObjectID()).toURL()
.openStream());
assert false : "shouldn't have worked, since it is private";
fail("shouldn't have worked, since it is private");
} catch (IOException e) {
}

View File

@ -19,6 +19,7 @@
package org.jclouds.byon.config;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.fail;
import java.io.IOException;
import java.io.InputStream;
@ -144,7 +145,7 @@ public class CacheNodeStoreModuleTest {
assertEquals(map.size(), 0);
try {
assertEquals(store.getUnchecked(key), null);
assert false : "should not work as null is invalid";
fail("should not work as null is invalid");
} catch (UncheckedExecutionException e) {
}

View File

@ -19,6 +19,7 @@
package org.jclouds.byon.config;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.fail;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@ -162,7 +163,7 @@ public class YamlNodeStoreModuleTest {
assertEquals(map.size(), 0);
try {
assertEquals(store.getUnchecked(key), null);
assert false : "should not work as null is invalid";
fail("should not work as null is invalid");
} catch (UncheckedExecutionException e) {
}

View File

@ -29,6 +29,7 @@ import static org.jclouds.cloudstack.compute.options.CloudStackTemplateOptions.B
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import java.util.Map;
@ -179,7 +180,7 @@ public class CloudStackTemplateOptionsTest {
public void testSecurityGroupIdsNullHasDecentMessage() {
try {
new CloudStackTemplateOptions().securityGroupIds(null);
assert false : "should NPE";
fail("should NPE");
} catch (NullPointerException e) {
assertEquals(e.getMessage(), "securityGroupIds was null");
}

View File

@ -20,6 +20,7 @@ package org.jclouds.cloudstack.features;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import java.io.IOException;
import java.net.HttpURLConnection;
@ -82,7 +83,7 @@ public class SecurityGroupClientLiveTest extends BaseCloudStackClientLiveTest {
checkGroup(group);
try {
client.getSecurityGroupClient().createSecurityGroup(prefix);
assert false;
fail("Expected IllegalStateException");
} catch (IllegalStateException e) {
}

View File

@ -23,6 +23,7 @@ import static org.jclouds.scriptbuilder.domain.Statements.exec;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.fail;
import java.io.IOException;
import java.net.UnknownHostException;
@ -233,7 +234,7 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest extends BaseComputeS
private void setUserDataForInstanceInRegion() {
try {
client.getInstanceServices().setUserDataForInstanceInRegion(null, instanceId, "test".getBytes());
assert false : "shouldn't be allowed, as instance needs to be stopped";
fail("shouldn't be allowed, as instance needs to be stopped");
} catch (AWSResponseException e) {
assertEquals("IncorrectInstanceState", e.getError().getCode());
}
@ -243,7 +244,7 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest extends BaseComputeS
try {
String ramdisk = client.getInstanceServices().getRamdiskForInstanceInRegion(null, instanceId);
client.getInstanceServices().setRamdiskForInstanceInRegion(null, instanceId, ramdisk);
assert false : "shouldn't be allowed, as instance needs to be stopped";
fail("shouldn't be allowed, as instance needs to be stopped");
} catch (AWSResponseException e) {
assertEquals("IncorrectInstanceState", e.getError().getCode());
}
@ -253,7 +254,7 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest extends BaseComputeS
try {
String oldKernel = client.getInstanceServices().getKernelForInstanceInRegion(null, instanceId);
client.getInstanceServices().setKernelForInstanceInRegion(null, instanceId, oldKernel);
assert false : "shouldn't be allowed, as instance needs to be stopped";
fail("shouldn't be allowed, as instance needs to be stopped");
} catch (AWSResponseException e) {
assertEquals("IncorrectInstanceState", e.getError().getCode());
}
@ -262,7 +263,7 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest extends BaseComputeS
private void setInstanceTypeForInstanceInRegion() {
try {
client.getInstanceServices().setInstanceTypeForInstanceInRegion(null, instanceId, InstanceType.C1_MEDIUM);
assert false : "shouldn't be allowed, as instance needs to be stopped";
fail("shouldn't be allowed, as instance needs to be stopped");
} catch (AWSResponseException e) {
assertEquals("IncorrectInstanceState", e.getError().getCode());
}
@ -272,7 +273,7 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest extends BaseComputeS
Map<String, BlockDevice> mapping = Maps.newLinkedHashMap();
try {
client.getInstanceServices().setBlockDeviceMappingForInstanceInRegion(null, instanceId, mapping);
assert false : "shouldn't be allowed, as instance needs to be ebs based-ami";
fail("shouldn't be allowed, as instance needs to be ebs based-ami");
} catch (AWSResponseException e) {
assertEquals("InvalidParameterCombination", e.getError().getCode());
}
@ -282,7 +283,7 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest extends BaseComputeS
try {
client.getInstanceServices().setInstanceInitiatedShutdownBehaviorForInstanceInRegion(null, instanceId,
InstanceInitiatedShutdownBehavior.STOP);
assert false : "shouldn't be allowed, as instance needs to be ebs based-ami";
fail("shouldn't be allowed, as instance needs to be ebs based-ami");
} catch (AWSResponseException e) {
assertEquals("UnsupportedInstanceAttribute", e.getError().getCode());
}

View File

@ -24,6 +24,7 @@ import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.c1_medium;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.fail;
import java.util.NoSuchElementException;
import java.util.Set;
@ -181,7 +182,7 @@ public class EC2TemplateBuilderImplTest extends TemplateBuilderImplTest {
optionsProvider, templateBuilderProvider);
try {
template.imageId("ami").build();
assert false;
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException e) {
}

View File

@ -18,6 +18,8 @@
*/
package org.jclouds.eucalyptus.compute;
import static org.testng.Assert.fail;
import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.ec2.compute.EC2ComputeServiceLiveTest;
@ -42,7 +44,7 @@ public class EucalyptusComputeServiceLiveTest extends EC2ComputeServiceLiveTest
public void testSuspendResume() throws Exception {
try {
super.testSuspendResume();
assert false;
fail("Expected HttpResponseException");
} catch (HttpResponseException e) {
// ebs backed not yet available
}

View File

@ -20,6 +20,7 @@ package org.jclouds.openstack.nova.v2_0.compute.loaders;
import static org.easymock.EasyMock.createMock;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.fail;
import java.util.concurrent.atomic.AtomicReference;
@ -80,7 +81,7 @@ public class FindSecurityGroupOrCreateTest {
@Override
public SecurityGroupInZone apply(ZoneSecurityGroupNameAndPorts input) {
assert false;
fail();
return null;
}
@ -105,7 +106,7 @@ public class FindSecurityGroupOrCreateTest {
@Override
public SecurityGroupInZone apply(ZoneSecurityGroupNameAndPorts input) {
assert false;
fail();
return null;
}
@ -130,7 +131,7 @@ public class FindSecurityGroupOrCreateTest {
@Override
public SecurityGroupInZone apply(ZoneSecurityGroupNameAndPorts input) {
assert false;
fail();
return null;
}

View File

@ -27,6 +27,7 @@ import static org.jclouds.trmk.vcloud_0_8.options.CloneVAppOptions.Builder.deplo
import static org.jclouds.trmk.vcloud_0_8.options.InstantiateVAppTemplateOptions.Builder.processorCount;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.fail;
import java.io.IOException;
import java.net.URI;
@ -348,13 +349,13 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
try {// per docs, this is not supported
connection.undeployVApp(vApp.getHref());
assert false;
fail("Expected UnsupportedOperationException");
} catch (UnsupportedOperationException e) {
}
try {// per docs, this is not supported
connection.suspendVApp(vApp.getHref());
assert false;
fail("Expected UnsupportedOperationException");
} catch (UnsupportedOperationException e) {
}

View File

@ -23,6 +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.fail;
import java.util.NoSuchElementException;
import java.util.Set;
@ -242,7 +243,7 @@ public class TemplateBuilderImplTest {
optionsProvider, templateBuilderProvider);
try {
template.imageId("us-east-1/imageId").build();
assert false;
fail("Expected NoSuchElementException");
} catch (NoSuchElementException e) {
// make sure message is succinct
assertEquals(e.getMessage(), "no hardware profiles support images matching params: idEquals(differentImageId)");
@ -380,7 +381,7 @@ public class TemplateBuilderImplTest {
try {
template.imageId("foo").locationId("location").build();
assert false;
fail("Expected NoSuchElementException");
} catch (NoSuchElementException e) {
}
@ -413,7 +414,7 @@ public class TemplateBuilderImplTest {
try {
template.imageId("foo").options(provideTemplateOptions()).locationId("location").build();
assert false;
fail("Expected NoSuchElementException");
} catch (NoSuchElementException e) {
}
@ -442,7 +443,7 @@ public class TemplateBuilderImplTest {
try {
template.os64Bit(true).build();
assert false;
fail("Expected IllegalStateException");
} catch (IllegalStateException e) {
assertEquals(e.getMessage(), "no images present!");
}
@ -470,7 +471,7 @@ public class TemplateBuilderImplTest {
try {
template.os64Bit(true).build();
assert false;
fail("Expected IllegalStateException");
} catch (IllegalStateException e) {
assertEquals(e.getMessage(), "no hardware profiles present!");
}
@ -499,7 +500,7 @@ public class TemplateBuilderImplTest {
try {
template.imageId("region/imageId2").build();
assert false;
fail("Expected NoSuchElementException");
} catch (NoSuchElementException e) {
// make sure big data is not in the exception message
assertEquals(e.getMessage(), "imageId(region/imageId2) not found");
@ -529,7 +530,7 @@ public class TemplateBuilderImplTest {
try {
template.imageDescriptionMatches("notDescription").build();
assert false;
fail("Expected NoSuchElementException");
} catch (NoSuchElementException e) {
// make sure big data is not in the exception message
assertEquals(e.getMessage(), "no image matched predicate: And(nullEqualToIsParentOrIsGrandparentOfCurrentLocation(),imageDescription(notDescription))");
@ -564,7 +565,7 @@ public class TemplateBuilderImplTest {
try {
template.imageId("region/ami").options(provideTemplateOptions()).build();
assert false;
fail("Expected NoSuchElementException");
} catch (NoSuchElementException e) {
}

View File

@ -43,6 +43,7 @@ import static org.jclouds.compute.predicates.NodePredicates.runningInGroup;
import static org.jclouds.compute.util.ComputeServiceUtils.getCores;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.fail;
import java.io.IOException;
import java.util.ArrayList;
@ -293,7 +294,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
ExecResponse response = null;
try {
response = future.get(1, TimeUnit.MILLISECONDS);
assert false : node.getId() + ": " + response;
fail(node.getId() + ": " + response);
} catch (TimeoutException e) {
assert !future.isDone();
response = client.runScriptOnNode(node.getId(), Statements.exec("/tmp/init-sleeper status"),
@ -305,7 +306,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
assert response.getOutput().trim().equals("") : node.getId() + ": " + response;
try {
future.get();
assert false : future;
fail(future.toString());
} catch (CancellationException e1) {
}

View File

@ -58,7 +58,7 @@ public class FutureIterablesTest {
}
}, MoreExecutors.sameThreadExecutor(), null, Logger.CONSOLE, "");
assert false;
fail("Expected AuthorizationException");
} catch (AuthorizationException e) {
assertEquals(counter.get(), 2);
}
@ -78,7 +78,7 @@ public class FutureIterablesTest {
}
}, MoreExecutors.sameThreadExecutor(), null, Logger.CONSOLE, "");
assert false;
fail("Expected TransformParallelException");
} catch (TransformParallelException e) {
assertEquals(e.getFromToException().size(), 2);
assertEquals(counter.get(), 10);

View File

@ -23,6 +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.fail;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
@ -80,7 +81,7 @@ public class FuturesTest {
CallGetAndRunExecutionList<String> caller = new CallGetAndRunExecutionList<String>(future, executionList);
try {
caller.run();
assert false;
fail("Expected IllegalStateException");
} catch (IllegalStateException e) {
assertEquals(e.getMessage(), "interrupted calling get() on [EasyMock for interface java.util.concurrent.Future], so could not run listeners");
}

View File

@ -23,6 +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.fail;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
@ -61,7 +62,7 @@ public class RetryOnTimeOutExceptionFunctionTest {
delegate);
try {
supplier.apply("baz");
assert false;
fail();
} catch (RuntimeException e) {
assertEquals(e.getCause(), timeout);
}
@ -113,7 +114,7 @@ public class RetryOnTimeOutExceptionFunctionTest {
try {
supplier.apply("baz");
assert false;
fail();
} catch (RuntimeException e) {
assertEquals(e.getCause(), auth);
}

View File

@ -23,6 +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.fail;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
@ -61,7 +62,7 @@ public class RetryOnTimeOutExceptionSupplierTest {
delegate);
try {
supplier.get();
assert false;
fail();
} catch (RuntimeException e) {
assertEquals(e.getCause(), timeout);
}
@ -113,7 +114,7 @@ public class RetryOnTimeOutExceptionSupplierTest {
try {
supplier.get();
assert false;
fail();
} catch (RuntimeException e) {
assertEquals(e.getCause(), auth);
}

View File

@ -23,6 +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.fail;
import java.io.IOException;
import java.util.concurrent.Callable;
@ -233,7 +234,7 @@ Caused by: java.lang.IllegalStateException: foo
static void checkFutureGetFailsWith(Future<?> task, String ...requiredPhrases) throws Exception {
try {
task.get();
assert false : "task should have failed";
fail("task should have failed");
} catch (ExecutionException e) {
String trace = Throwables.getStackTraceAsString(e);
for (String requiredPhrase : requiredPhrases) {

View File

@ -19,6 +19,7 @@
package org.jclouds.functions;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.fail;
import java.util.concurrent.ExecutionException;
@ -56,14 +57,14 @@ public class CacheLearningTest {
});
try {
cache.get("foo");
assert false : "expected exception on miss";
fail("expected exception on miss");
} catch (CacheLoader.InvalidCacheLoadException e) {
assertEquals(e.getMessage(), "CacheLoader returned null for key foo.");
}
try {
cache.getUnchecked("foo");
assert false : "expected exception on miss";
fail("expected exception on miss");
} catch (CacheLoader.InvalidCacheLoadException e) {
assertEquals(e.getMessage(), "CacheLoader returned null for key foo.");
}
@ -85,21 +86,21 @@ public class CacheLearningTest {
try {
cache.get("exception");
assert false : "expected checked exception in loader to rethrow as ExecutionException";
fail("expected checked exception in loader to rethrow as ExecutionException");
} catch (ExecutionException e) {
assertEquals(e.getMessage(), "java.lang.Exception: exception");
}
try {
cache.get("runtimeexception");
assert false : "expected unchecked exception in loader to rethrow as UncheckedExecutionException";
fail("expected unchecked exception in loader to rethrow as UncheckedExecutionException");
} catch (UncheckedExecutionException e) {
assertEquals(e.getMessage(), "java.lang.RuntimeException: runtimeexception");
}
try {
cache.getUnchecked("exception");
assert false : "expected checked exception in loader to rethrow as UncheckedExecutionException, when getUnchecked called";
fail("expected checked exception in loader to rethrow as UncheckedExecutionException, when getUnchecked called");
} catch (UncheckedExecutionException e) {
assertEquals(e.getMessage(), "java.lang.Exception: exception");
}

View File

@ -19,6 +19,7 @@
package org.jclouds.location.suppliers.implicit;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.fail;
import java.util.NoSuchElementException;
import java.util.Set;
@ -55,7 +56,7 @@ public class FirstNetworkTest {
try {
fn.get();
assert false;
fail("Expected NoSuchElementException");
} catch (NoSuchElementException e) {
assertEquals(e.getMessage(), "none of the locations are scope NETWORK: [servo:PROVIDER, servo-r:REGION]");
}

View File

@ -19,6 +19,7 @@
package org.jclouds.location.suppliers.implicit;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.fail;
import java.util.NoSuchElementException;
import java.util.Set;
@ -54,7 +55,7 @@ public class FirstRegionTest {
try {
fn.get();
assert false;
fail("Expected NoSuchElementException");
} catch (NoSuchElementException e) {
assertEquals(e.getMessage(), "none to of the locations are scope REGION: [servo:PROVIDER, servo-z:ZONE]");
}

View File

@ -19,6 +19,7 @@
package org.jclouds.location.suppliers.implicit;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.fail;
import java.util.NoSuchElementException;
import java.util.Set;
@ -54,7 +55,7 @@ public class FirstZoneTest {
try {
fn.get();
assert false;
fail("Expected NoSuchElementException");
} catch (NoSuchElementException e) {
assertEquals(e.getMessage(), "none to of the locations are scope ZONE: [servo:PROVIDER, servo-r:REGION]");
}

View File

@ -19,6 +19,7 @@
package org.jclouds.location.suppliers.implicit;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.fail;
import java.util.NoSuchElementException;
import java.util.Set;
@ -57,7 +58,7 @@ public class OnlyLocationOrFirstRegionOptionallyMatchingRegionIdTest {
try {
fn.get();
assert false;
fail("Expected NoSuchElementException");
} catch (NoSuchElementException e) {
assertEquals(
e.getMessage(),

View File

@ -19,6 +19,7 @@
package org.jclouds.location.suppliers.implicit;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.fail;
import java.util.NoSuchElementException;
import java.util.Set;
@ -54,7 +55,7 @@ public class OnlyLocationOrFirstZoneTest {
try {
fn.get();
assert false;
fail("Expected NoSuchElementException");
} catch (NoSuchElementException e) {
assertEquals(e.getMessage(), "none to of the locations are scope ZONE: [servo:PROVIDER, servo-r:REGION]");
}

View File

@ -23,6 +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.fail;
import org.jclouds.http.HttpResponse;
import org.jclouds.http.HttpResponseException;
@ -68,7 +69,7 @@ public class MapHttp4xxCodesToExceptionsTest {
try {
function.apply(responseException);
assert false;
fail();
} catch (Exception e) {
assertEquals(e.getClass(), expected);
}

View File

@ -25,6 +25,7 @@ import static org.jclouds.io.Payloads.newInputStreamPayload;
import static org.jclouds.io.Payloads.newStringPayload;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.fail;
import java.io.File;
import java.io.IOException;
@ -278,7 +279,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest {
try {
child.getInstance(AsyncCallee.class);
assert false : "Callee shouldn't be bound yet";
fail("Callee shouldn't be bound yet");
} catch (ConfigurationException e) {
}
@ -302,7 +303,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest {
try {
child.getInstance(Callee.class);
assert false : "Callee shouldn't be bound yet";
fail("Callee shouldn't be bound yet");
} catch (ConfigurationException e) {
}
@ -327,7 +328,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest {
try {
child.getInstance(AsyncCallee.class);
assert false : "Callee shouldn't be bound yet";
fail("Callee shouldn't be bound yet");
} catch (ConfigurationException e) {
}
@ -352,7 +353,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest {
try {
child.getInstance(AsyncCallee.class);
assert false : "Callee shouldn't be bound yet";
fail("Callee shouldn't be bound yet");
} catch (ConfigurationException e) {
}
@ -376,7 +377,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest {
try {
child.getInstance(AsyncCallee.class);
assert false : "Callee shouldn't be bound yet";
fail("Callee shouldn't be bound yet");
} catch (ConfigurationException e) {
}
@ -415,7 +416,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest {
try {
child.getInstance(AsyncCallee.class);
assert false : "Callee shouldn't be bound yet";
fail("Callee shouldn't be bound yet");
} catch (ConfigurationException e) {
}
@ -440,7 +441,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest {
try {
child.getInstance(Callee.class);
assert false : "Callee shouldn't be bound yet";
fail("Callee shouldn't be bound yet");
} catch (ConfigurationException e) {
}

View File

@ -27,6 +27,7 @@ import static org.jclouds.compute.predicates.NodePredicates.runningInGroup;
import static org.jclouds.scriptbuilder.domain.Statements.exec;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.fail;
import java.io.FileNotFoundException;
import java.io.IOException;
@ -177,7 +178,7 @@ public class AWSKeyPairClientLiveTest extends BaseComputeServiceContextLiveTest
// try again to see if there's an error
try {
client.importKeyPairInRegion(null, keyName, myKey.get("public"));
assert false;
fail("Expected IllegalStateException");
} catch (IllegalStateException e) {
}

View File

@ -23,6 +23,7 @@ import static com.google.common.collect.Lists.newArrayList;
import static com.google.common.collect.Sets.newTreeSet;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.fail;
import java.util.ArrayList;
import java.util.Set;
@ -106,7 +107,7 @@ public class PlacementGroupClientLiveTest extends BaseComputeServiceContextLiveT
if (!supportedRegions.contains(region))
try {
client.getPlacementGroupServices().describePlacementGroupsInRegion(region);
assert false : "should be unsupported for region: " + region;
fail("should be unsupported for region: " + region);
} catch (UnsupportedOperationException e) {
}
}

View File

@ -2,6 +2,7 @@ package org.jclouds.gogrid.services;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import java.net.URI;
@ -110,7 +111,7 @@ public class GridServerClientExpectTest extends BaseGoGridRestClientExpectTest {
GoGridClient clientWhenGridServersNotFound = requestSendsResponse(listGridServers, listGridServersResponse);
try {
clientWhenGridServersNotFound.getServerServices().getServerCredentials(11);
assert false : "should have failed";
fail("should have failed");
} catch (ResourceNotFoundException e) {
assertEquals(e.getMessage(), "No object found that matches your input criteria.");
}

View File

@ -20,6 +20,7 @@ package org.jclouds.softlayer.compute.options;
import static org.jclouds.softlayer.compute.options.SoftLayerTemplateOptions.Builder.domainName;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.fail;
import org.jclouds.compute.options.TemplateOptions;
import org.testng.annotations.Test;
@ -61,7 +62,7 @@ public class SoftLayerTemplateOptionsTest {
public void testDomainNameNullHasDecentMessage() {
try {
new SoftLayerTemplateOptions().domainName(null);
assert false : "should NPE";
fail("should NPE");
} catch (NullPointerException e) {
assertEquals(e.getMessage(), "domainName was null");
}

View File

@ -24,6 +24,7 @@ import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import java.io.InputStream;
import java.net.URI;
@ -209,7 +210,7 @@ public class PCSClientLiveTest {
try {
connection.downloadFile(uriBuilderProvider.get().uri(objectURI).path("sad").build());
assert false;
fail("Expected KeyNotFoundException");
} catch (KeyNotFoundException e) {
}
// Test GET of object (including updated metadata)