From 0761874578fc0497520a1e4135d03c6d58f4d9d0 Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Sat, 3 Nov 2012 14:50:54 -0700 Subject: [PATCH] Prefer Assert.fail over assert The former cannot be disabled. --- .../org/jclouds/atmos/AtmosClientLiveTest.java | 3 ++- .../byon/config/CacheNodeStoreModuleTest.java | 3 ++- .../byon/config/YamlNodeStoreModuleTest.java | 3 ++- .../options/CloudStackTemplateOptionsTest.java | 3 ++- .../features/SecurityGroupClientLiveTest.java | 3 ++- ...plicationArchitecturesEC2ClientLiveTest.java | 13 +++++++------ .../internal/EC2TemplateBuilderImplTest.java | 3 ++- .../EucalyptusComputeServiceLiveTest.java | 4 +++- .../loaders/FindSecurityGroupOrCreateTest.java | 7 ++++--- .../vcloud_0_8/TerremarkClientLiveTest.java | 5 +++-- .../internal/TemplateBuilderImplTest.java | 17 +++++++++-------- .../internal/BaseComputeServiceLiveTest.java | 5 +++-- .../jclouds/concurrent/FutureIterablesTest.java | 4 ++-- .../org/jclouds/concurrent/FuturesTest.java | 3 ++- .../RetryOnTimeOutExceptionFunctionTest.java | 5 +++-- .../RetryOnTimeOutExceptionSupplierTest.java | 5 +++-- .../config/ExecutorServiceModuleTest.java | 3 ++- .../jclouds/functions/CacheLearningTest.java | 11 ++++++----- .../suppliers/implicit/FirstNetworkTest.java | 3 ++- .../suppliers/implicit/FirstRegionTest.java | 3 ++- .../suppliers/implicit/FirstZoneTest.java | 3 ++- ...rstRegionOptionallyMatchingRegionIdTest.java | 3 ++- .../implicit/OnlyLocationOrFirstZoneTest.java | 3 ++- .../MapHttp4xxCodesToExceptionsTest.java | 3 ++- .../internal/RestAnnotationProcessorTest.java | 15 ++++++++------- .../ec2/services/AWSKeyPairClientLiveTest.java | 3 ++- .../services/PlacementGroupClientLiveTest.java | 3 ++- .../services/GridServerClientExpectTest.java | 3 ++- .../options/SoftLayerTemplateOptionsTest.java | 3 ++- .../jclouds/mezeo/pcs/PCSClientLiveTest.java | 3 ++- 30 files changed, 89 insertions(+), 59 deletions(-) diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/AtmosClientLiveTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/AtmosClientLiveTest.java index d54c06169d..33c558ea59 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/AtmosClientLiveTest.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/AtmosClientLiveTest.java @@ -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) { } diff --git a/apis/byon/src/test/java/org/jclouds/byon/config/CacheNodeStoreModuleTest.java b/apis/byon/src/test/java/org/jclouds/byon/config/CacheNodeStoreModuleTest.java index 862597908b..11688cc664 100644 --- a/apis/byon/src/test/java/org/jclouds/byon/config/CacheNodeStoreModuleTest.java +++ b/apis/byon/src/test/java/org/jclouds/byon/config/CacheNodeStoreModuleTest.java @@ -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) { } diff --git a/apis/byon/src/test/java/org/jclouds/byon/config/YamlNodeStoreModuleTest.java b/apis/byon/src/test/java/org/jclouds/byon/config/YamlNodeStoreModuleTest.java index 89ab073278..00ffc9f255 100644 --- a/apis/byon/src/test/java/org/jclouds/byon/config/YamlNodeStoreModuleTest.java +++ b/apis/byon/src/test/java/org/jclouds/byon/config/YamlNodeStoreModuleTest.java @@ -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) { } diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/options/CloudStackTemplateOptionsTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/options/CloudStackTemplateOptionsTest.java index 01555ff1fc..1308dbd7b1 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/options/CloudStackTemplateOptionsTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/options/CloudStackTemplateOptionsTest.java @@ -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"); } diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SecurityGroupClientLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SecurityGroupClientLiveTest.java index 5b33cacad9..4b5fe84bf4 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SecurityGroupClientLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SecurityGroupClientLiveTest.java @@ -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) { } diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ClientLiveTest.java index ad21a91cf6..2b8ccb275d 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ClientLiveTest.java @@ -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 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()); } diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/internal/EC2TemplateBuilderImplTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/internal/EC2TemplateBuilderImplTest.java index 8b96ed9d45..0e3466f591 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/internal/EC2TemplateBuilderImplTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/internal/EC2TemplateBuilderImplTest.java @@ -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) { } diff --git a/apis/eucalyptus/src/test/java/org/jclouds/eucalyptus/compute/EucalyptusComputeServiceLiveTest.java b/apis/eucalyptus/src/test/java/org/jclouds/eucalyptus/compute/EucalyptusComputeServiceLiveTest.java index 49f4f34b19..59cc2b990f 100644 --- a/apis/eucalyptus/src/test/java/org/jclouds/eucalyptus/compute/EucalyptusComputeServiceLiveTest.java +++ b/apis/eucalyptus/src/test/java/org/jclouds/eucalyptus/compute/EucalyptusComputeServiceLiveTest.java @@ -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 } diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/compute/loaders/FindSecurityGroupOrCreateTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/compute/loaders/FindSecurityGroupOrCreateTest.java index f2869e6ffa..0dc4a13de4 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/compute/loaders/FindSecurityGroupOrCreateTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/compute/loaders/FindSecurityGroupOrCreateTest.java @@ -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; } diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/TerremarkClientLiveTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/TerremarkClientLiveTest.java index 737ca279f8..5fbf4d2f52 100644 --- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/TerremarkClientLiveTest.java +++ b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/TerremarkClientLiveTest.java @@ -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 caller = new CallGetAndRunExecutionList(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"); } diff --git a/core/src/test/java/org/jclouds/concurrent/RetryOnTimeOutExceptionFunctionTest.java b/core/src/test/java/org/jclouds/concurrent/RetryOnTimeOutExceptionFunctionTest.java index 80a693819d..2a0546e081 100644 --- a/core/src/test/java/org/jclouds/concurrent/RetryOnTimeOutExceptionFunctionTest.java +++ b/core/src/test/java/org/jclouds/concurrent/RetryOnTimeOutExceptionFunctionTest.java @@ -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); } diff --git a/core/src/test/java/org/jclouds/concurrent/RetryOnTimeOutExceptionSupplierTest.java b/core/src/test/java/org/jclouds/concurrent/RetryOnTimeOutExceptionSupplierTest.java index 9584f3ff53..a770f611e0 100644 --- a/core/src/test/java/org/jclouds/concurrent/RetryOnTimeOutExceptionSupplierTest.java +++ b/core/src/test/java/org/jclouds/concurrent/RetryOnTimeOutExceptionSupplierTest.java @@ -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); } diff --git a/core/src/test/java/org/jclouds/concurrent/config/ExecutorServiceModuleTest.java b/core/src/test/java/org/jclouds/concurrent/config/ExecutorServiceModuleTest.java index 1e7a70b79f..1be5d2ae51 100644 --- a/core/src/test/java/org/jclouds/concurrent/config/ExecutorServiceModuleTest.java +++ b/core/src/test/java/org/jclouds/concurrent/config/ExecutorServiceModuleTest.java @@ -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) { diff --git a/core/src/test/java/org/jclouds/functions/CacheLearningTest.java b/core/src/test/java/org/jclouds/functions/CacheLearningTest.java index 24be4e5258..37b6a67f38 100644 --- a/core/src/test/java/org/jclouds/functions/CacheLearningTest.java +++ b/core/src/test/java/org/jclouds/functions/CacheLearningTest.java @@ -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"); } diff --git a/core/src/test/java/org/jclouds/location/suppliers/implicit/FirstNetworkTest.java b/core/src/test/java/org/jclouds/location/suppliers/implicit/FirstNetworkTest.java index 520ade127b..f7dc2e74a4 100644 --- a/core/src/test/java/org/jclouds/location/suppliers/implicit/FirstNetworkTest.java +++ b/core/src/test/java/org/jclouds/location/suppliers/implicit/FirstNetworkTest.java @@ -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]"); } diff --git a/core/src/test/java/org/jclouds/location/suppliers/implicit/FirstRegionTest.java b/core/src/test/java/org/jclouds/location/suppliers/implicit/FirstRegionTest.java index 6a37593013..e660c0dae4 100644 --- a/core/src/test/java/org/jclouds/location/suppliers/implicit/FirstRegionTest.java +++ b/core/src/test/java/org/jclouds/location/suppliers/implicit/FirstRegionTest.java @@ -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]"); } diff --git a/core/src/test/java/org/jclouds/location/suppliers/implicit/FirstZoneTest.java b/core/src/test/java/org/jclouds/location/suppliers/implicit/FirstZoneTest.java index d9f523d8fc..7b0ec40b0a 100644 --- a/core/src/test/java/org/jclouds/location/suppliers/implicit/FirstZoneTest.java +++ b/core/src/test/java/org/jclouds/location/suppliers/implicit/FirstZoneTest.java @@ -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]"); } diff --git a/core/src/test/java/org/jclouds/location/suppliers/implicit/OnlyLocationOrFirstRegionOptionallyMatchingRegionIdTest.java b/core/src/test/java/org/jclouds/location/suppliers/implicit/OnlyLocationOrFirstRegionOptionallyMatchingRegionIdTest.java index e398f1088b..34822efd7a 100644 --- a/core/src/test/java/org/jclouds/location/suppliers/implicit/OnlyLocationOrFirstRegionOptionallyMatchingRegionIdTest.java +++ b/core/src/test/java/org/jclouds/location/suppliers/implicit/OnlyLocationOrFirstRegionOptionallyMatchingRegionIdTest.java @@ -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(), diff --git a/core/src/test/java/org/jclouds/location/suppliers/implicit/OnlyLocationOrFirstZoneTest.java b/core/src/test/java/org/jclouds/location/suppliers/implicit/OnlyLocationOrFirstZoneTest.java index a5fcaed7b1..b443d75d29 100644 --- a/core/src/test/java/org/jclouds/location/suppliers/implicit/OnlyLocationOrFirstZoneTest.java +++ b/core/src/test/java/org/jclouds/location/suppliers/implicit/OnlyLocationOrFirstZoneTest.java @@ -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]"); } diff --git a/core/src/test/java/org/jclouds/rest/functions/MapHttp4xxCodesToExceptionsTest.java b/core/src/test/java/org/jclouds/rest/functions/MapHttp4xxCodesToExceptionsTest.java index 083cbcada6..7a48286332 100644 --- a/core/src/test/java/org/jclouds/rest/functions/MapHttp4xxCodesToExceptionsTest.java +++ b/core/src/test/java/org/jclouds/rest/functions/MapHttp4xxCodesToExceptionsTest.java @@ -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); } diff --git a/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java b/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java index f1a8736d8a..d6b057b79d 100644 --- a/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java +++ b/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java @@ -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) { } diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairClientLiveTest.java index 15a4030046..3e055f7b36 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairClientLiveTest.java @@ -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) { } diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java index dc93bd90f3..2bfbff2410 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java @@ -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) { } } diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridServerClientExpectTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridServerClientExpectTest.java index 73f4489ada..5f41c58d3c 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridServerClientExpectTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridServerClientExpectTest.java @@ -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."); } diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/options/SoftLayerTemplateOptionsTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/options/SoftLayerTemplateOptionsTest.java index 5988d3f232..a4ffb3b37e 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/options/SoftLayerTemplateOptionsTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/options/SoftLayerTemplateOptionsTest.java @@ -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"); } diff --git a/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/PCSClientLiveTest.java b/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/PCSClientLiveTest.java index aa36dd16e1..d6baafbf9f 100644 --- a/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/PCSClientLiveTest.java +++ b/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/PCSClientLiveTest.java @@ -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)