brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [1/7] brooklyn-server git commit: fix tests which were strict about the error, and deprecation
Date Wed, 17 Feb 2016 00:31:38 GMT
Repository: brooklyn-server
Updated Branches:
  refs/heads/master 3f02cccac -> a5103bba5


fix tests which were strict about the error, and deprecation


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/7b9f8c71
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/7b9f8c71
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/7b9f8c71

Branch: refs/heads/master
Commit: 7b9f8c714dfb62acaf61d2e1027d6b6b5e410182
Parents: 3db19cf
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Tue Feb 9 16:28:44 2016 +0000
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Tue Feb 16 17:53:03 2016 +0000

----------------------------------------------------------------------
 .../brooklyn/catalog/CatalogYamlRebindTest.java |  9 ++--
 .../brooklyn/util/core/flags/TypeCoercions.java |  2 +-
 .../mgmt/rebind/RebindCatalogEntityTest.java    | 13 +++--
 .../RebindManagerExceptionHandlerTest.java      | 19 +++----
 .../core/mgmt/rebind/RebindTestFixture.java     | 11 ++---
 .../mgmt/rebind/RebindTestFixtureWithApp.java   |  3 +-
 .../rest/resources/ApidocResourceTest.java      | 44 ++++++++---------
 .../rest/resources/ApplicationResourceTest.java |  2 +-
 .../rest/resources/CatalogResourceTest.java     |  4 +-
 .../InfrastructureDeploymentTestCaseTest.java   | 52 +++++++-------------
 .../test/framework/TestEffectorTest.java        | 26 +++++-----
 11 files changed, 81 insertions(+), 104 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/7b9f8c71/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlRebindTest.java
----------------------------------------------------------------------
diff --git a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlRebindTest.java
b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlRebindTest.java
index 989bdb3..747f630 100644
--- a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlRebindTest.java
+++ b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlRebindTest.java
@@ -24,7 +24,6 @@ import static org.testng.Assert.assertFalse;
 import static org.testng.Assert.assertNotNull;
 import static org.testng.Assert.assertNull;
 import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
 
 import java.io.StringReader;
 import java.io.StringWriter;
@@ -54,6 +53,7 @@ import org.apache.brooklyn.core.mgmt.rebind.RebindOptions;
 import org.apache.brooklyn.core.test.policy.TestEnricher;
 import org.apache.brooklyn.core.test.policy.TestPolicy;
 import org.apache.brooklyn.entity.stock.BasicEntity;
+import org.apache.brooklyn.test.Asserts;
 import org.apache.brooklyn.util.exceptions.Exceptions;
 import org.apache.brooklyn.util.text.Strings;
 import org.testng.annotations.Test;
@@ -283,13 +283,14 @@ public class CatalogYamlRebindTest extends AbstractYamlRebindTest {
         } else {
             try {
                 StartableApplication app2 = (StartableApplication) createAndStartApplication(yaml2);
-                fail();
+                Asserts.shouldHaveFailedPreviously();
             } catch (Exception e) {
+                // only these two modes are allowed; may have different assertions (but don't
yet)
                 if (mode == RebindWithCatalogTestMode.DELETE_CATALOG) {
-                    if (!e.toString().contains("cannot be matched")) throw e;
+                    Asserts.expectedFailureContainsIgnoreCase(e, "unable to match", "my.catalog.app");
                 } else {
                     assertEquals(mode, RebindWithCatalogTestMode.DISABLE_CATALOG);
-                    if (!e.toString().contains("cannot be matched")) throw e;
+                    Asserts.expectedFailureContainsIgnoreCase(e, "unable to match", "my.catalog.app");
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/7b9f8c71/core/src/main/java/org/apache/brooklyn/util/core/flags/TypeCoercions.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/util/core/flags/TypeCoercions.java b/core/src/main/java/org/apache/brooklyn/util/core/flags/TypeCoercions.java
index 4029a71..65f85d6 100644
--- a/core/src/main/java/org/apache/brooklyn/util/core/flags/TypeCoercions.java
+++ b/core/src/main/java/org/apache/brooklyn/util/core/flags/TypeCoercions.java
@@ -282,7 +282,7 @@ public class TypeCoercions {
                 // fall back to below
             }
         }
-        throw new ClassCoercionException("Cannot coerce type "+value.getClass()+" to "+targetType.getCanonicalName()+"
("+value+"): no adapter known");
+        throw new ClassCoercionException("Cannot coerce type "+value.getClass().getCanonicalName()+"
to "+targetType.getCanonicalName()+" ("+value+"): no adapter known");
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/7b9f8c71/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindCatalogEntityTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindCatalogEntityTest.java
b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindCatalogEntityTest.java
index 6a034c4..5cfa97a 100644
--- a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindCatalogEntityTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindCatalogEntityTest.java
@@ -26,13 +26,8 @@ import java.io.Closeable;
 import java.net.URL;
 import java.util.List;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
 import org.apache.brooklyn.api.entity.Application;
 import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.api.mgmt.ManagementContext;
 import org.apache.brooklyn.api.mgmt.ha.ManagementNodeState;
 import org.apache.brooklyn.core.catalog.internal.CatalogInitialization;
 import org.apache.brooklyn.core.config.ConfigKeys;
@@ -40,11 +35,14 @@ import org.apache.brooklyn.core.entity.AbstractApplication;
 import org.apache.brooklyn.core.entity.Entities;
 import org.apache.brooklyn.core.entity.EntityInternal;
 import org.apache.brooklyn.core.entity.StartableApplication;
-import org.apache.brooklyn.core.entity.factory.ApplicationBuilder;
 import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext;
 import org.apache.brooklyn.core.sensor.Sensors;
 import org.apache.brooklyn.test.support.TestResourceUnavailableException;
 import org.apache.brooklyn.util.core.javalang.UrlClassLoader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
 
 import com.google.common.base.Function;
 
@@ -94,6 +92,7 @@ public class RebindCatalogEntityTest extends RebindTestFixture<StartableApplicat
     //       AbstractMemento.injectTypeClass(Class)
     //
     // NB: this behaviour is generally deprecated in favour of OSGi now.
+    @SuppressWarnings("resource")
     @Test 
     public void testRestoresAppFromCatalogClassloader() throws Exception {
         @SuppressWarnings("unchecked")
@@ -102,7 +101,7 @@ public class RebindCatalogEntityTest extends RebindTestFixture<StartableApplicat
         
         EntitySpec<StartableApplication> appSpec = EntitySpec.create(StartableApplication.class,
appClazz)
                 .configure("myconf", "myconfval");
-        origApp = ApplicationBuilder.newManagedApp(appSpec, origManagementContext);
+        origApp = origManagementContext.getEntityManager().createEntity(appSpec);
         ((EntityInternal)origApp).sensors().set(Sensors.newStringSensor("mysensor"), "mysensorval");
         
         newApp = rebindWithAppClass();

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/7b9f8c71/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindManagerExceptionHandlerTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindManagerExceptionHandlerTest.java
b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindManagerExceptionHandlerTest.java
index d50ab55..7ac31df 100644
--- a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindManagerExceptionHandlerTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindManagerExceptionHandlerTest.java
@@ -18,22 +18,22 @@
  */
 package org.apache.brooklyn.core.mgmt.rebind;
 
-import com.google.common.collect.ImmutableMap;
 import org.apache.brooklyn.api.entity.EntitySpec;
 import org.apache.brooklyn.api.mgmt.ManagementContext;
-import org.apache.brooklyn.core.entity.factory.ApplicationBuilder;
+import org.apache.brooklyn.core.entity.EntityAsserts;
 import org.apache.brooklyn.core.internal.BrooklynProperties;
 import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext;
 import org.apache.brooklyn.core.test.entity.TestApplication;
 import org.apache.brooklyn.core.test.entity.TestApplicationNoEnrichersImpl;
 import org.apache.brooklyn.core.test.entity.TestEntity;
-import org.apache.brooklyn.test.EntityTestUtils;
-import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.apache.brooklyn.test.Asserts;
 import org.testng.annotations.Test;
 
+import com.google.common.collect.ImmutableMap;
+
 public class RebindManagerExceptionHandlerTest extends RebindTestFixtureWithApp {
 
-    @Test(expectedExceptions = {IllegalStateException.class, IllegalArgumentException.class})
+    @Test
     public void testAddConfigFailure() throws Throwable {
         origApp.createAndManageChild(EntitySpec.create(TestEntity.class)
                 .configure("test.confMapThing", ImmutableMap.of("keyWithMapValue", ImmutableMap.of("minRam",
4))));
@@ -44,15 +44,16 @@ public class RebindManagerExceptionHandlerTest extends RebindTestFixtureWithApp
             // Use the original context with empty properties so the test doesn't depend
on the local properties file
             rebindOptions.newManagementContext = origManagementContext;
             rebind(rebindOptions);
-        } catch (Exception e) {
-            throw Exceptions.getFirstInteresting(e);
+            Asserts.shouldHaveFailedPreviously();
+        } catch (Throwable e) {
+            Asserts.expectedFailureContainsIgnoreCase(e, "minRam=4", "keyWithMapValue");
         }
     }
 
     @Test
     public void testAddConfigContinue() throws Throwable {
         ManagementContext m = createManagementContextWithAddConfigContinue();
-        origApp = ApplicationBuilder.newManagedApp(EntitySpec.create(TestApplication.class,
TestApplicationNoEnrichersImpl.class), m);
+        origApp = m.getEntityManager().createEntity(EntitySpec.create(TestApplication.class,
TestApplicationNoEnrichersImpl.class));
         origApp.createAndManageChild(EntitySpec.create(TestEntity.class)
                 .configure("test.confMapThing", ImmutableMap.of("keyWithMapValue", ImmutableMap.of("minRam",
4))));
 
@@ -60,7 +61,7 @@ public class RebindManagerExceptionHandlerTest extends RebindTestFixtureWithApp
         RebindOptions rebindOptions = RebindOptions.create();
         rebindOptions.newManagementContext = m;
         TestApplication rebindedApp = rebind(rebindOptions);
-        EntityTestUtils.assertConfigEquals(rebindedApp, TestEntity.CONF_MAP_THING, null);
+        EntityAsserts.assertConfigEquals(rebindedApp, TestEntity.CONF_MAP_THING, null);
     }
 
     private LocalManagementContext createManagementContextWithAddConfigContinue() {

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/7b9f8c71/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindTestFixture.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindTestFixture.java
b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindTestFixture.java
index 0135229..f43042f 100644
--- a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindTestFixture.java
+++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindTestFixture.java
@@ -19,18 +19,12 @@
 package org.apache.brooklyn.core.mgmt.rebind;
 
 import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
 
 import java.io.File;
 import java.util.List;
 import java.util.Set;
 import java.util.concurrent.Callable;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
 import org.apache.brooklyn.api.catalog.BrooklynCatalog;
 import org.apache.brooklyn.api.catalog.CatalogItem;
 import org.apache.brooklyn.api.entity.Application;
@@ -55,6 +49,10 @@ import org.apache.brooklyn.util.os.Os;
 import org.apache.brooklyn.util.repeat.Repeater;
 import org.apache.brooklyn.util.text.Identifiers;
 import org.apache.brooklyn.util.time.Duration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
 
 import com.google.common.collect.FluentIterable;
 import com.google.common.collect.Iterables;
@@ -306,7 +304,6 @@ public abstract class RebindTestFixture<T extends StartableApplication>
{
         assertEquals(actual.getId(), expected.getId());
         assertEquals(actual.getDisplayName(), expected.getDisplayName());
         assertEquals(actual.getVersion(), expected.getVersion());
-        assertEquals(actual.getJavaType(), expected.getJavaType());
         assertEquals(actual.getDescription(), expected.getDescription());
         assertEquals(actual.getIconUrl(), expected.getIconUrl());
         assertEquals(actual.getVersion(), expected.getVersion());

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/7b9f8c71/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindTestFixtureWithApp.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindTestFixtureWithApp.java
b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindTestFixtureWithApp.java
index 554d73d..2a7e443 100644
--- a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindTestFixtureWithApp.java
+++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindTestFixtureWithApp.java
@@ -19,14 +19,13 @@
 package org.apache.brooklyn.core.mgmt.rebind;
 
 import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.core.entity.factory.ApplicationBuilder;
 import org.apache.brooklyn.core.test.entity.TestApplication;
 import org.apache.brooklyn.core.test.entity.TestApplicationNoEnrichersImpl;
 
 public class RebindTestFixtureWithApp extends RebindTestFixture<TestApplication> {
 
     protected TestApplication createApp() {
-        return ApplicationBuilder.newManagedApp(EntitySpec.create(TestApplication.class,
TestApplicationNoEnrichersImpl.class), origManagementContext);
+        return origManagementContext.getEntityManager().createEntity(EntitySpec.create(TestApplication.class,
TestApplicationNoEnrichersImpl.class));
     }
     
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/7b9f8c71/rest/rest-server/src/test/java/org/apache/brooklyn/rest/resources/ApidocResourceTest.java
----------------------------------------------------------------------
diff --git a/rest/rest-server/src/test/java/org/apache/brooklyn/rest/resources/ApidocResourceTest.java
b/rest/rest-server/src/test/java/org/apache/brooklyn/rest/resources/ApidocResourceTest.java
index 739d63f..2064508 100644
--- a/rest/rest-server/src/test/java/org/apache/brooklyn/rest/resources/ApidocResourceTest.java
+++ b/rest/rest-server/src/test/java/org/apache/brooklyn/rest/resources/ApidocResourceTest.java
@@ -18,6 +18,24 @@
  */
 package org.apache.brooklyn.rest.resources;
 
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import io.swagger.annotations.Api;
+import io.swagger.models.Operation;
+import io.swagger.models.Path;
+import io.swagger.models.Swagger;
+
+import java.util.Collection;
+
+import org.apache.brooklyn.rest.BrooklynRestApi;
+import org.apache.brooklyn.rest.api.CatalogApi;
+import org.apache.brooklyn.rest.api.EffectorApi;
+import org.apache.brooklyn.rest.api.EntityApi;
+import org.apache.brooklyn.rest.filter.SwaggerFilter;
+import org.apache.brooklyn.rest.testing.BrooklynRestResourceTest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.Test;
 
 import com.google.common.base.Function;
 import com.google.common.base.Joiner;
@@ -28,34 +46,12 @@ import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Iterables;
 import com.sun.jersey.api.core.ClassNamesResourceConfig;
 import com.sun.jersey.spi.container.servlet.ServletContainer;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import org.apache.brooklyn.rest.BrooklynRestApi;
-import org.apache.brooklyn.rest.testing.BrooklynRestResourceTest;
-
 import com.sun.jersey.test.framework.AppDescriptor;
 import com.sun.jersey.test.framework.JerseyTest;
 import com.sun.jersey.test.framework.WebAppDescriptor;
 import com.sun.jersey.test.framework.spi.container.TestContainerException;
 import com.sun.jersey.test.framework.spi.container.TestContainerFactory;
 import com.sun.jersey.test.framework.spi.container.grizzly2.web.GrizzlyWebTestContainerFactory;
-import io.swagger.annotations.Api;
-import io.swagger.models.Info;
-import io.swagger.models.Operation;
-import io.swagger.models.Path;
-import io.swagger.models.Swagger;
-import java.util.Collection;
-import org.apache.brooklyn.rest.api.CatalogApi;
-import org.apache.brooklyn.rest.api.EffectorApi;
-import org.apache.brooklyn.rest.api.EntityApi;
-import org.apache.brooklyn.rest.filter.SwaggerFilter;
-import org.apache.brooklyn.rest.util.ShutdownHandlerProvider;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
 
 /**
  * @author Adam Lowe
@@ -83,9 +79,9 @@ public class ApidocResourceTest extends BrooklynRestResourceTest {
             }
 
             private String getResourceClassnames() {
-                Iterable<String> classnames = Collections2.transform(config.getClasses(),
new Function<Class, String>() {
+                Iterable<String> classnames = Collections2.transform(config.getClasses(),
new Function<Class<?>, String>() {
                     @Override
-                    public String apply(Class clazz) {
+                    public String apply(Class<?> clazz) {
                         return clazz.getName();
                     }
                 });

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/7b9f8c71/rest/rest-server/src/test/java/org/apache/brooklyn/rest/resources/ApplicationResourceTest.java
----------------------------------------------------------------------
diff --git a/rest/rest-server/src/test/java/org/apache/brooklyn/rest/resources/ApplicationResourceTest.java
b/rest/rest-server/src/test/java/org/apache/brooklyn/rest/resources/ApplicationResourceTest.java
index 8b49763..ada548b 100644
--- a/rest/rest-server/src/test/java/org/apache/brooklyn/rest/resources/ApplicationResourceTest.java
+++ b/rest/rest-server/src/test/java/org/apache/brooklyn/rest/resources/ApplicationResourceTest.java
@@ -649,7 +649,7 @@ public class ApplicationResourceTest extends BrooklynRestResourceTest
{
                     .entity(yaml3, "application/x-yaml")
                     .post(ClientResponse.class);
             HttpAsserts.assertClientErrorStatusCode(response3.getStatus());
-            assertTrue(response3.getEntity(String.class).contains("cannot be matched"));
+            assertTrue(response3.getEntity(String.class).toLowerCase().contains("unable to
match"));
             waitForPageNotFoundResponse("/v1/applications/my-app3", ApplicationSummary.class);
             
         } finally {

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/7b9f8c71/rest/rest-server/src/test/java/org/apache/brooklyn/rest/resources/CatalogResourceTest.java
----------------------------------------------------------------------
diff --git a/rest/rest-server/src/test/java/org/apache/brooklyn/rest/resources/CatalogResourceTest.java
b/rest/rest-server/src/test/java/org/apache/brooklyn/rest/resources/CatalogResourceTest.java
index 921d6fc..14bbb2f 100644
--- a/rest/rest-server/src/test/java/org/apache/brooklyn/rest/resources/CatalogResourceTest.java
+++ b/rest/rest-server/src/test/java/org/apache/brooklyn/rest/resources/CatalogResourceTest.java
@@ -129,6 +129,7 @@ public class CatalogResourceTest extends BrooklynRestResourceTest {
         // an InterfacesTag should be created for every catalog item
         assertEquals(entityItem.getTags().size(), 1);
         Object tag = entityItem.getTags().iterator().next();
+        @SuppressWarnings("unchecked")
         List<String> actualInterfaces = ((Map<String, List<String>>) tag).get("traits");
         List<Class<?>> expectedInterfaces = Reflections.getAllInterfaces(TestEntity.class);
         assertEquals(actualInterfaces.size(), expectedInterfaces.size());
@@ -141,6 +142,7 @@ public class CatalogResourceTest extends BrooklynRestResourceTest {
     }
 
     @Test
+    // osgi fails in IDE, should work on CLI though
     public void testRegisterOsgiPolicyTopLevelSyntax() {
         TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_PATH);
 
@@ -503,7 +505,7 @@ public class CatalogResourceTest extends BrooklynRestResourceTest {
         ClientResponse response = client().resource("/v1/catalog")
                 .post(ClientResponse.class, yaml);
 
-        assertEquals(response.getStatus(), HttpStatus.INTERNAL_SERVER_ERROR_500);
+        assertEquals(response.getStatus(), HttpStatus.BAD_REQUEST_400);
     }
 
     private static String ver(String id) {

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/7b9f8c71/test-framework/src/test/java/org/apache/brooklyn/test/framework/InfrastructureDeploymentTestCaseTest.java
----------------------------------------------------------------------
diff --git a/test-framework/src/test/java/org/apache/brooklyn/test/framework/InfrastructureDeploymentTestCaseTest.java
b/test-framework/src/test/java/org/apache/brooklyn/test/framework/InfrastructureDeploymentTestCaseTest.java
index fa0e864..5928c15 100644
--- a/test-framework/src/test/java/org/apache/brooklyn/test/framework/InfrastructureDeploymentTestCaseTest.java
+++ b/test-framework/src/test/java/org/apache/brooklyn/test/framework/InfrastructureDeploymentTestCaseTest.java
@@ -23,19 +23,10 @@ import static org.apache.brooklyn.core.entity.trait.Startable.SERVICE_UP;
 import static org.apache.brooklyn.test.Asserts.fail;
 import static org.assertj.core.api.Assertions.assertThat;
 
-import java.util.Collection;
 import java.util.List;
 
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.reflect.TypeToken;
-
 import org.apache.brooklyn.api.entity.Entity;
 import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.api.entity.ImplementedBy;
 import org.apache.brooklyn.api.location.Location;
 import org.apache.brooklyn.api.location.LocationSpec;
 import org.apache.brooklyn.api.mgmt.ManagementContext;
@@ -47,13 +38,19 @@ import org.apache.brooklyn.entity.software.base.EmptySoftwareProcess;
 import org.apache.brooklyn.entity.software.base.SoftwareProcess;
 import org.apache.brooklyn.entity.stock.BasicApplication;
 import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
+import org.apache.brooklyn.test.Asserts;
 import org.apache.brooklyn.test.framework.entity.TestInfrastructure;
-import org.apache.brooklyn.util.exceptions.Exceptions;
-import org.apache.brooklyn.util.text.Identifiers;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.reflect.TypeToken;
 
 /**
  * @author Graeme Miller on 27/10/2015.
  */
+@SuppressWarnings("serial")
 public class InfrastructureDeploymentTestCaseTest {
 
     private TestApplication app;
@@ -65,8 +62,7 @@ public class InfrastructureDeploymentTestCaseTest {
 
     private static final AttributeSensorAndConfigKey<Location, Location> DEPLOYMENT_LOCATION_SENSOR
=
             ConfigKeys.newSensorAndConfigKey(
-                    new TypeToken<Location>() {
-                    },
+                    new TypeToken<Location>() {},
                     "deploymentLocationSensor", "The location to deploy to");
 
     @BeforeMethod
@@ -184,12 +180,9 @@ public class InfrastructureDeploymentTestCaseTest {
 
         try {
             app.start(ImmutableList.of(app.newSimulatedLocation()));
-            fail("Should have thrown execption");
+            Asserts.shouldHaveFailedPreviously();
         } catch (Throwable throwable) {
-            Throwable firstInteresting = Exceptions.getFirstInteresting(throwable);
-            assertThat(firstInteresting).isNotNull();
-            assertThat(throwable).isNotNull();
-            assertThat(firstInteresting).isInstanceOf(IllegalArgumentException.class);
+            Asserts.expectedFailure(throwable);
         }
 
         assertThat(infrastructureDeploymentTestCase.sensors().get(SERVICE_UP)).isFalse();
@@ -206,14 +199,11 @@ public class InfrastructureDeploymentTestCaseTest {
 
         try {
             app.start(ImmutableList.of(app.newSimulatedLocation()));
-            fail("Should have thrown execption");
+            Asserts.shouldHaveFailedPreviously();
         } catch (Throwable throwable) {
-            Throwable firstInteresting = Exceptions.getFirstInteresting(throwable);
-            assertThat(firstInteresting).isNotNull();
-            assertThat(throwable).isNotNull();
-            assertThat(firstInteresting).isInstanceOf(IllegalArgumentException.class);
+            Asserts.expectedFailure(throwable);
         }
-
+        
         assertThat(infrastructureDeploymentTestCase.sensors().get(SERVICE_UP)).isFalse();
     }
 
@@ -230,12 +220,9 @@ public class InfrastructureDeploymentTestCaseTest {
 
         try {
             app.start(ImmutableList.of(app.newSimulatedLocation()));
-            fail("Should have thrown execption");
+            Asserts.shouldHaveFailedPreviously();
         } catch (Throwable throwable) {
-            Throwable firstInteresting = Exceptions.getFirstInteresting(throwable);
-            assertThat(firstInteresting).isNotNull();
-            assertThat(throwable).isNotNull();
-            assertThat(firstInteresting).isInstanceOf(IllegalArgumentException.class);
+            Asserts.expectedFailure(throwable);
         }
 
         assertThat(infrastructureDeploymentTestCase.sensors().get(SERVICE_UP)).isFalse();
@@ -254,12 +241,9 @@ public class InfrastructureDeploymentTestCaseTest {
 
         try {
             app.start(ImmutableList.of(app.newSimulatedLocation()));
-            fail("Should have thrown execption");
+            Asserts.shouldHaveFailedPreviously();
         } catch (Throwable throwable) {
-            Throwable firstInteresting = Exceptions.getFirstInteresting(throwable);
-            assertThat(firstInteresting).isNotNull();
-            assertThat(throwable).isNotNull();
-            assertThat(firstInteresting).isInstanceOf(IllegalArgumentException.class);
+            Asserts.expectedFailure(throwable);
         }
 
         assertThat(infrastructureDeploymentTestCase.sensors().get(SERVICE_UP)).isFalse();

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/7b9f8c71/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEffectorTest.java
----------------------------------------------------------------------
diff --git a/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEffectorTest.java
b/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEffectorTest.java
index d0c6b8c..b1d987c 100644
--- a/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEffectorTest.java
+++ b/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEffectorTest.java
@@ -19,27 +19,27 @@
 
 package org.apache.brooklyn.test.framework;
 
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
+import static org.apache.brooklyn.core.entity.trait.Startable.SERVICE_UP;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.List;
+import java.util.Map;
+
 import org.apache.brooklyn.api.entity.EntitySpec;
 import org.apache.brooklyn.api.location.LocationSpec;
 import org.apache.brooklyn.api.mgmt.ManagementContext;
 import org.apache.brooklyn.core.entity.Entities;
 import org.apache.brooklyn.core.test.entity.TestApplication;
 import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
+import org.apache.brooklyn.test.Asserts;
 import org.apache.brooklyn.test.framework.entity.TestEntity;
-import org.apache.brooklyn.util.exceptions.Exceptions;
 import org.apache.brooklyn.util.text.Identifiers;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
-import static org.apache.brooklyn.core.entity.trait.Startable.SERVICE_UP;
-import static org.apache.brooklyn.test.Asserts.fail;
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.util.List;
-import java.util.Map;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
 
 /**
  * @author m4rkmckenna on 27/10/2015.
@@ -48,6 +48,7 @@ public class TestEffectorTest {
 
     private TestApplication app;
     private ManagementContext managementContext;
+    @SuppressWarnings("unused")
     private LocalhostMachineProvisioningLocation loc;
     private String testId;
 
@@ -136,12 +137,9 @@ public class TestEffectorTest {
 
         try {
             app.start(ImmutableList.of(app.newSimulatedLocation()));
-            fail("Should have thrown execption");
+            Asserts.shouldHaveFailedPreviously();
         } catch (Throwable throwable) {
-            Throwable firstInteresting = Exceptions.getFirstInteresting(throwable);
-            assertThat(firstInteresting).isNotNull();
-            assertThat(throwable).isNotNull();
-            assertThat(firstInteresting).isInstanceOf(AssertionError.class);
+            Asserts.expectedFailureOfType(throwable, AssertionError.class);
         }
 
         assertThat(testEffector.sensors().get(SERVICE_UP)).isFalse().withFailMessage("Service
should not be up");


Mime
View raw message