You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by ri...@apache.org on 2014/12/01 18:11:41 UTC

[1/4] incubator-brooklyn git commit: Make embedded jars optional

Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master 4b11fea2b -> c2451f3e3


Make embedded jars optional

Modifies code that relies on jar files as an embedded resource to
gracefully handle cases where the files are missing. Limited to tests,
which will cause TestNG to skip the test if the resource is missing.
Required for our source distribution, as Apache convention is to not
ship binaries in releases.


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

Branch: refs/heads/master
Commit: 7e5360d755b86de81919ee287b090e51f1ed67f0
Parents: 824dc15
Author: Richard Downer <ri...@apache.org>
Authored: Wed Nov 26 13:08:09 2014 +0000
Committer: Richard Downer <ri...@apache.org>
Committed: Mon Dec 1 17:04:35 2014 +0000

----------------------------------------------------------------------
 .../entity/rebind/RebindCatalogEntityTest.java  |  6 ++--
 .../management/osgi/OsgiStandaloneTest.java     | 30 ++++++++++++++------
 .../osgi/OsgiVersionMoreEntityTest.java         | 21 ++++++++++++++
 .../entity/rebind/brooklyn-AppInCatalog.txt     |  5 +++-
 .../osgi/brooklyn-osgi-test-a_0.1.0.txt         |  5 +++-
 .../osgi/brooklyn-test-osgi-entities.txt        |  5 ++++
 .../brooklyn-test-osgi-more-entities_0.1.0.txt  |  5 ++++
 .../brooklyn-test-osgi-more-entities_0.2.0.txt  |  5 ++++
 ...-test-osgi-more-entities_evil-twin_0.2.0.txt |  5 ++++
 .../cassandra/cassandra-multicloud-snitch.txt   |  6 +++-
 .../entity/osgi/karaf/KarafContainerTest.java   | 10 +++++--
 .../osgi/src/test/resources/hello-world.txt     |  5 +++-
 12 files changed, 90 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7e5360d7/core/src/test/java/brooklyn/entity/rebind/RebindCatalogEntityTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/rebind/RebindCatalogEntityTest.java b/core/src/test/java/brooklyn/entity/rebind/RebindCatalogEntityTest.java
index 2e3c621..cf9e5fe 100644
--- a/core/src/test/java/brooklyn/entity/rebind/RebindCatalogEntityTest.java
+++ b/core/src/test/java/brooklyn/entity/rebind/RebindCatalogEntityTest.java
@@ -25,6 +25,7 @@ import static org.testng.Assert.assertNotSame;
 import java.net.URL;
 import java.util.List;
 
+import brooklyn.test.TestResourceUnavailableException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.annotations.BeforeMethod;
@@ -59,7 +60,7 @@ public class RebindCatalogEntityTest extends RebindTestFixture<StartableApplicat
      * }
      */
 
-    private static final String JAR_PATH = "brooklyn/entity/rebind/brooklyn-AppInCatalog.jar";
+    private static final String JAR_PATH = "/brooklyn/entity/rebind/brooklyn-AppInCatalog.jar";
     private static final String APP_CLASSNAME = "brooklyn.entity.rebind.AppInCatalog";
 
     private URL url;
@@ -78,7 +79,8 @@ public class RebindCatalogEntityTest extends RebindTestFixture<StartableApplicat
     @BeforeMethod(alwaysRun=true)
     @Override
     public void setUp() throws Exception {
-        url = getClass().getClassLoader().getResource(JAR_PATH);
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), JAR_PATH);
+        url = getClass().getResource(JAR_PATH);
         assertNotNull(url, "Could not find on classpath: "+JAR_PATH);
         super.setUp();
     }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7e5360d7/core/src/test/java/brooklyn/management/osgi/OsgiStandaloneTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/management/osgi/OsgiStandaloneTest.java b/core/src/test/java/brooklyn/management/osgi/OsgiStandaloneTest.java
index 6d2cbc8..54ecb02 100644
--- a/core/src/test/java/brooklyn/management/osgi/OsgiStandaloneTest.java
+++ b/core/src/test/java/brooklyn/management/osgi/OsgiStandaloneTest.java
@@ -26,6 +26,8 @@ import java.util.Enumeration;
 import java.util.List;
 import java.util.jar.JarInputStream;
 
+import brooklyn.test.TestResourceUnavailableException;
+import brooklyn.util.exceptions.Exceptions;
 import org.apache.commons.io.FileUtils;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleException;
@@ -99,15 +101,24 @@ public class OsgiStandaloneTest {
         }
     }
 
+    protected Bundle installFromClasspath(String resourceName) throws BundleException {
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), resourceName);
+        try {
+            return Osgis.install(framework, String.format("classpath:%s", resourceName));
+        } catch (Exception e) {
+            throw Exceptions.propagate(e);
+        }
+    }
+
     @Test
     public void testInstallBundle() throws Exception {
-        Bundle bundle = install(BROOKLYN_OSGI_TEST_A_0_1_0_URL);
+        Bundle bundle = installFromClasspath(BROOKLYN_OSGI_TEST_A_0_1_0_PATH);
         checkMath(bundle, 3, 6);
     }
 
     @Test
     public void testBootBundle() throws Exception {
-        Bundle bundle = install(BROOKLYN_TEST_OSGI_ENTITIES_PATH);
+        Bundle bundle = installFromClasspath(BROOKLYN_TEST_OSGI_ENTITIES_PATH);
         Class<?> bundleCls = bundle.loadClass("brooklyn.osgi.tests.SimpleEntity");
         Assert.assertEquals(Entity.class,  bundle.loadClass(Entity.class.getName()));
         Assert.assertEquals(Entity.class, bundleCls.getClassLoader().loadClass(Entity.class.getName()));
@@ -139,7 +150,7 @@ public class OsgiStandaloneTest {
 
     @Test
     public void testAMultiplier() throws Exception {
-        Bundle bundle = install(BROOKLYN_OSGI_TEST_A_0_1_0_URL);
+        Bundle bundle = installFromClasspath(BROOKLYN_OSGI_TEST_A_0_1_0_PATH);
         checkMath(bundle, 3, 6);
         setAMultiplier(bundle, 5);
         checkMath(bundle, 3, 15);
@@ -149,7 +160,7 @@ public class OsgiStandaloneTest {
      * on a fresh install the multiplier is reset */
     @Test
     public void testANOtherMultiple() throws Exception {
-        Bundle bundle = install(BROOKLYN_OSGI_TEST_A_0_1_0_URL);
+        Bundle bundle = installFromClasspath(BROOKLYN_OSGI_TEST_A_0_1_0_PATH);
         checkMath(bundle, 3, 6);
         setAMultiplier(bundle, 14);
         checkMath(bundle, 3, 42);
@@ -157,23 +168,23 @@ public class OsgiStandaloneTest {
 
     @Test
     public void testGetBundle() throws Exception {
-        Bundle bundle = install(BROOKLYN_OSGI_TEST_A_0_1_0_URL);
+        Bundle bundle = installFromClasspath(BROOKLYN_OSGI_TEST_A_0_1_0_PATH);
         setAMultiplier(bundle, 3);
 
         // can look it up based on the same location string (no other "location identifier" reference string seems to work here, however) 
-        Bundle bundle2 = install(BROOKLYN_OSGI_TEST_A_0_1_0_URL);
+        Bundle bundle2 = installFromClasspath(BROOKLYN_OSGI_TEST_A_0_1_0_PATH);
         checkMath(bundle2, 3, 9);
     }
 
     @Test
     public void testUninstallAndReinstallBundle() throws Exception {
-        Bundle bundle = install(BROOKLYN_OSGI_TEST_A_0_1_0_URL);
+        Bundle bundle = installFromClasspath(BROOKLYN_OSGI_TEST_A_0_1_0_PATH);
         checkMath(bundle, 3, 6);
         setAMultiplier(bundle, 3);
         checkMath(bundle, 3, 9);
         bundle.uninstall();
         
-        Bundle bundle2 = install(BROOKLYN_OSGI_TEST_A_0_1_0_URL);
+        Bundle bundle2 = installFromClasspath(BROOKLYN_OSGI_TEST_A_0_1_0_PATH);
         checkMath(bundle2, 3, 6);
     }
 
@@ -209,6 +220,7 @@ public class OsgiStandaloneTest {
     
     @Test
     public void testReadKnownManifest() throws Exception {
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), BROOKLYN_TEST_OSGI_ENTITIES_PATH);
         InputStream in = this.getClass().getResourceAsStream(BROOKLYN_TEST_OSGI_ENTITIES_PATH);
         JarInputStream jarIn = new JarInputStream(in);
         ManifestHelper helper = Osgis.ManifestHelper.forManifest(jarIn.getManifest());
@@ -219,7 +231,7 @@ public class OsgiStandaloneTest {
     
     @Test
     public void testLoadOsgiBundleDependencies() throws Exception {
-        Bundle bundle = install(BROOKLYN_TEST_OSGI_ENTITIES_URL);
+        Bundle bundle = installFromClasspath(BROOKLYN_TEST_OSGI_ENTITIES_PATH);
         Assert.assertNotNull(bundle);
         Class<?> aClass = bundle.loadClass("brooklyn.osgi.tests.SimpleApplicationImpl");
         Object aInst = aClass.newInstance();

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7e5360d7/core/src/test/java/brooklyn/management/osgi/OsgiVersionMoreEntityTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/management/osgi/OsgiVersionMoreEntityTest.java b/core/src/test/java/brooklyn/management/osgi/OsgiVersionMoreEntityTest.java
index fd6baef..e8d9860 100644
--- a/core/src/test/java/brooklyn/management/osgi/OsgiVersionMoreEntityTest.java
+++ b/core/src/test/java/brooklyn/management/osgi/OsgiVersionMoreEntityTest.java
@@ -24,6 +24,7 @@ import java.lang.reflect.InvocationTargetException;
 import java.util.Arrays;
 import java.util.List;
 
+import brooklyn.test.TestResourceUnavailableException;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.launch.Framework;
@@ -106,6 +107,7 @@ public class OsgiVersionMoreEntityTest {
             InternalPolicyFactory policyFactory = new InternalPolicyFactory(managementContext);
             factory = new InternalEntityFactory(managementContext, managementContext.getEntityManager().getEntityTypeRegistry(), policyFactory);
 
+            TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), BROOKLYN_TEST_OSGI_ENTITIES_PATH);
             Bundle bundle = Osgis.install(framework, BROOKLYN_TEST_OSGI_ENTITIES_PATH);
             @SuppressWarnings("unchecked")
             Class<? extends Entity> bundleCls = (Class<? extends Entity>) bundle.loadClass("brooklyn.osgi.tests.SimpleEntityImpl");
@@ -188,6 +190,8 @@ public class OsgiVersionMoreEntityTest {
 
     @Test
     public void testMoreEntitiesV1() throws Exception {
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), BROOKLYN_TEST_MORE_ENTITIES_V1_PATH);
+
         CatalogItem<?, ?> c2 = addCatalogItemWithTypeAsName(
                 OsgiTestResources.BROOKLYN_TEST_MORE_ENTITIES_MORE_ENTITY,
                 TEST_VERSION,
@@ -217,6 +221,9 @@ public class OsgiVersionMoreEntityTest {
 
     @Test
     public void testMoreEntitiesV1Policy() throws Exception {
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), BROOKLYN_TEST_MORE_ENTITIES_V1_PATH);
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), BROOKLYN_TEST_OSGI_ENTITIES_PATH);
+
         CatalogItem<?, ?> c2 = addCatalogItemWithTypeAsName(
                 OsgiTestResources.BROOKLYN_TEST_MORE_ENTITIES_MORE_ENTITY,
                 TEST_VERSION,
@@ -242,6 +249,8 @@ public class OsgiVersionMoreEntityTest {
 
     @Test
     public void testMoreEntitiesV2FailsWithoutBasicTestOsgiEntitiesBundle() throws Exception {
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), BROOKLYN_TEST_MORE_ENTITIES_V2_PATH);
+
         CatalogItem<?, ?> c2 = addCatalogItemWithTypeAsName(
                 OsgiTestResources.BROOKLYN_TEST_MORE_ENTITIES_MORE_ENTITY,
                 TEST_VERSION,
@@ -262,6 +271,8 @@ public class OsgiVersionMoreEntityTest {
     // and has policy, with policy item catalog ID is reasonable
     @Test
     public void testMoreEntitiesV2() throws Exception {
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), BROOKLYN_TEST_MORE_ENTITIES_V2_PATH);
+
         CatalogItem<?, ?> c2 = addCatalogItemWithTypeAsName(
                 OsgiTestResources.BROOKLYN_TEST_MORE_ENTITIES_MORE_ENTITY,
                 TEST_VERSION,
@@ -284,6 +295,9 @@ public class OsgiVersionMoreEntityTest {
 
     @Test
     public void testMoreEntitiesV1ThenV2GivesV2() throws Exception {
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), BROOKLYN_TEST_MORE_ENTITIES_V1_PATH);
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), BROOKLYN_TEST_MORE_ENTITIES_V2_PATH);
+
         addCatalogItemWithTypeAsName(
                 OsgiTestResources.BROOKLYN_TEST_MORE_ENTITIES_MORE_ENTITY,
                 TEST_VERSION,
@@ -303,6 +317,9 @@ public class OsgiVersionMoreEntityTest {
 
     @Test
     public void testMoreEntitiesV2ThenV1GivesV1() throws Exception {
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), BROOKLYN_TEST_MORE_ENTITIES_V1_PATH);
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), BROOKLYN_TEST_MORE_ENTITIES_V2_PATH);
+
         addCatalogItemWithTypeAsName(
                 OsgiTestResources.BROOKLYN_TEST_MORE_ENTITIES_MORE_ENTITY,
                 TEST_VERSION,
@@ -345,6 +362,10 @@ public class OsgiVersionMoreEntityTest {
 
     @Test
     public void testUnfazedByMoreEntitiesV1AndV2AndV2EvilTwin() throws Exception {
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), BROOKLYN_TEST_MORE_ENTITIES_V1_PATH);
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), BROOKLYN_TEST_MORE_ENTITIES_V2_PATH);
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), BROOKLYN_TEST_MORE_ENTITIES_V2_EVIL_TWIN_PATH);
+
         addCatalogItemWithNameAndType("v1",
                 TEST_VERSION,
                 OsgiTestResources.BROOKLYN_TEST_MORE_ENTITIES_MORE_ENTITY,

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7e5360d7/core/src/test/resources/brooklyn/entity/rebind/brooklyn-AppInCatalog.txt
----------------------------------------------------------------------
diff --git a/core/src/test/resources/brooklyn/entity/rebind/brooklyn-AppInCatalog.txt b/core/src/test/resources/brooklyn/entity/rebind/brooklyn-AppInCatalog.txt
index 5c5a4c5..b4f6a9f 100644
--- a/core/src/test/resources/brooklyn/entity/rebind/brooklyn-AppInCatalog.txt
+++ b/core/src/test/resources/brooklyn/entity/rebind/brooklyn-AppInCatalog.txt
@@ -21,5 +21,8 @@ on the classpath.
 
 The jar contains its source code. 
 
-It is included as a (small) binary to prevent build complication.
+Under Apache conventions, binary files are not part of the source
+release. If you are using the source release, you may add this file
+by copying it from the master repository, which is accessible on the
+web at https://github.com/apache/incubator-brooklyn
 ~

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7e5360d7/core/src/test/resources/brooklyn/osgi/brooklyn-osgi-test-a_0.1.0.txt
----------------------------------------------------------------------
diff --git a/core/src/test/resources/brooklyn/osgi/brooklyn-osgi-test-a_0.1.0.txt b/core/src/test/resources/brooklyn/osgi/brooklyn-osgi-test-a_0.1.0.txt
index dfe77bc..e6dde72 100644
--- a/core/src/test/resources/brooklyn/osgi/brooklyn-osgi-test-a_0.1.0.txt
+++ b/core/src/test/resources/brooklyn/osgi/brooklyn-osgi-test-a_0.1.0.txt
@@ -20,4 +20,7 @@ used in brooklyn.management.osgi.OsgiStandaloneTest.
 
 The jar contains its source.
 
-It is included here in binary form to simplify the Brooklyn build process.
+Under Apache conventions, binary files are not part of the source
+release. If you are using the source release, you may add this file
+by copying it from the master repository, which is accessible on the
+web at https://github.com/apache/incubator-brooklyn

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7e5360d7/core/src/test/resources/brooklyn/osgi/brooklyn-test-osgi-entities.txt
----------------------------------------------------------------------
diff --git a/core/src/test/resources/brooklyn/osgi/brooklyn-test-osgi-entities.txt b/core/src/test/resources/brooklyn/osgi/brooklyn-test-osgi-entities.txt
index 74cc33d..9cf43a4 100644
--- a/core/src/test/resources/brooklyn/osgi/brooklyn-test-osgi-entities.txt
+++ b/core/src/test/resources/brooklyn/osgi/brooklyn-test-osgi-entities.txt
@@ -19,3 +19,8 @@ The file brooklyn-test-osgi-entities.jar is for testing a deployment of
 an OSGi bundle containing entities.
 
 The source is in core/src/test/dependencies/osgi/entities
+
+Under Apache conventions, binary files are not part of the source
+release. If you are using the source release, you may add this file
+by copying it from the master repository, which is accessible on the
+web at https://github.com/apache/incubator-brooklyn

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7e5360d7/core/src/test/resources/brooklyn/osgi/brooklyn-test-osgi-more-entities_0.1.0.txt
----------------------------------------------------------------------
diff --git a/core/src/test/resources/brooklyn/osgi/brooklyn-test-osgi-more-entities_0.1.0.txt b/core/src/test/resources/brooklyn/osgi/brooklyn-test-osgi-more-entities_0.1.0.txt
index b1879d7..80067a4 100644
--- a/core/src/test/resources/brooklyn/osgi/brooklyn-test-osgi-more-entities_0.1.0.txt
+++ b/core/src/test/resources/brooklyn/osgi/brooklyn-test-osgi-more-entities_0.1.0.txt
@@ -19,3 +19,8 @@ The file brooklyn-test-osgi-entities.jar is for testing a deployment of
 an OSGi bundle containing entities.
 
 The source is in core/src/test/dependencies/osgi/more-entities-v1
+
+Under Apache conventions, binary files are not part of the source
+release. If you are using the source release, you may add this file
+by copying it from the master repository, which is accessible on the
+web at https://github.com/apache/incubator-brooklyn

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7e5360d7/core/src/test/resources/brooklyn/osgi/brooklyn-test-osgi-more-entities_0.2.0.txt
----------------------------------------------------------------------
diff --git a/core/src/test/resources/brooklyn/osgi/brooklyn-test-osgi-more-entities_0.2.0.txt b/core/src/test/resources/brooklyn/osgi/brooklyn-test-osgi-more-entities_0.2.0.txt
index bd307eb..3fb2d31 100644
--- a/core/src/test/resources/brooklyn/osgi/brooklyn-test-osgi-more-entities_0.2.0.txt
+++ b/core/src/test/resources/brooklyn/osgi/brooklyn-test-osgi-more-entities_0.2.0.txt
@@ -19,3 +19,8 @@ The file brooklyn-test-osgi-entities.jar is for testing a deployment of
 an OSGi bundle containing entities.
 
 The source is in core/src/test/dependencies/osgi/more-entities-v2
+
+Under Apache conventions, binary files are not part of the source
+release. If you are using the source release, you may add this file
+by copying it from the master repository, which is accessible on the
+web at https://github.com/apache/incubator-brooklyn

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7e5360d7/core/src/test/resources/brooklyn/osgi/brooklyn-test-osgi-more-entities_evil-twin_0.2.0.txt
----------------------------------------------------------------------
diff --git a/core/src/test/resources/brooklyn/osgi/brooklyn-test-osgi-more-entities_evil-twin_0.2.0.txt b/core/src/test/resources/brooklyn/osgi/brooklyn-test-osgi-more-entities_evil-twin_0.2.0.txt
index 9597d3b..1b9c2ab 100644
--- a/core/src/test/resources/brooklyn/osgi/brooklyn-test-osgi-more-entities_evil-twin_0.2.0.txt
+++ b/core/src/test/resources/brooklyn/osgi/brooklyn-test-osgi-more-entities_evil-twin_0.2.0.txt
@@ -19,3 +19,8 @@ The file brooklyn-test-osgi-entities.jar is for testing a deployment of
 an OSGi bundle containing entities.
 
 The source is in core/src/test/dependencies/osgi/more-entities-v2-evil-twin
+
+Under Apache conventions, binary files are not part of the source
+release. If you are using the source release, you may add this file
+by copying it from the master repository, which is accessible on the
+web at https://github.com/apache/incubator-brooklyn

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7e5360d7/software/nosql/src/main/resources/brooklyn/entity/nosql/cassandra/cassandra-multicloud-snitch.txt
----------------------------------------------------------------------
diff --git a/software/nosql/src/main/resources/brooklyn/entity/nosql/cassandra/cassandra-multicloud-snitch.txt b/software/nosql/src/main/resources/brooklyn/entity/nosql/cassandra/cassandra-multicloud-snitch.txt
index bc4d3a2..205b18d 100644
--- a/software/nosql/src/main/resources/brooklyn/entity/nosql/cassandra/cassandra-multicloud-snitch.txt
+++ b/software/nosql/src/main/resources/brooklyn/entity/nosql/cassandra/cassandra-multicloud-snitch.txt
@@ -24,6 +24,10 @@ The source will be contributed to the Cassandra project; when it is available in
 Cassandra distro (and when we don't want to give backwards compatibility support for
 older Cassandra versions), then we can delete it from Brooklyn.
 
-It is included here in binary form to simplify the Brooklyn build process.
 The jar can be uploaded to a Cassandra Node as part of deployment, for if
 this multi-cloud snitch is desired.
+
+Under Apache conventions, binary files are not part of the source
+release. If you are using the source release, you may add this file
+by copying it from the master repository, which is accessible on the
+web at https://github.com/apache/incubator-brooklyn

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7e5360d7/software/osgi/src/test/java/brooklyn/entity/osgi/karaf/KarafContainerTest.java
----------------------------------------------------------------------
diff --git a/software/osgi/src/test/java/brooklyn/entity/osgi/karaf/KarafContainerTest.java b/software/osgi/src/test/java/brooklyn/entity/osgi/karaf/KarafContainerTest.java
index f43255d..f54e5ae 100644
--- a/software/osgi/src/test/java/brooklyn/entity/osgi/karaf/KarafContainerTest.java
+++ b/software/osgi/src/test/java/brooklyn/entity/osgi/karaf/KarafContainerTest.java
@@ -24,6 +24,7 @@ import static org.testng.Assert.assertNull;
 import java.net.URL;
 import java.util.Map;
 
+import brooklyn.test.TestResourceUnavailableException;
 import org.testng.Assert;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
@@ -44,6 +45,8 @@ import com.google.common.collect.ImmutableList;
 
 public class KarafContainerTest extends BrooklynAppLiveTestSupport {
 
+    private static final String HELLO_WORLD_JAR = "/hello-world.jar";
+
     LocalhostMachineProvisioningLocation localhost;
     KarafContainer karaf;
 
@@ -116,6 +119,10 @@ public class KarafContainerTest extends BrooklynAppLiveTestSupport {
     // registered so we are never able to connect to them over jmx.
     @Test(groups = {"Integration", "WIP"})
     public void testCanInstallAndUninstallBundle() throws Exception {
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), HELLO_WORLD_JAR);
+        URL jarUrl = getClass().getResource(HELLO_WORLD_JAR);
+        assertNotNull(jarUrl);
+
         karaf = app.createAndManageChild(EntitySpec.create(KarafContainer.class)
             .configure("name", Identifiers.makeRandomId(8))
             .configure("displayName", "Karaf Test")
@@ -124,9 +131,6 @@ public class KarafContainerTest extends BrooklynAppLiveTestSupport {
         
         app.start(ImmutableList.of(localhost));
         
-        URL jarUrl = getClass().getClassLoader().getResource("hello-world.jar");
-        assertNotNull(jarUrl);
-        
         long bundleId = karaf.installBundle("wrap:"+jarUrl.toString());
         
         Map<Long, Map<String,?>> bundles = karaf.listBundles();

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7e5360d7/software/osgi/src/test/resources/hello-world.txt
----------------------------------------------------------------------
diff --git a/software/osgi/src/test/resources/hello-world.txt b/software/osgi/src/test/resources/hello-world.txt
index 0d88aa6..f3060f0 100644
--- a/software/osgi/src/test/resources/hello-world.txt
+++ b/software/osgi/src/test/resources/hello-world.txt
@@ -20,4 +20,7 @@ simple OSGi bundle that can be deployed.
 
 The jar contains its source code.
 
-It is included as a (small) binary to prevent build complication.
+Under Apache conventions, binary files are not part of the source
+release. If you are using the source release, you may add this file
+by copying it from the master repository, which is accessible on the
+web at https://github.com/apache/incubator-brooklyn


[4/4] incubator-brooklyn git commit: Merge and close #365 [BROOKLYN-29]

Posted by ri...@apache.org.
Merge and close #365 [BROOKLYN-29]


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

Branch: refs/heads/master
Commit: c2451f3e3f22b2da6204ee7016ea177b8ec1192c
Parents: 4b11fea dc90382
Author: Richard Downer <ri...@apache.org>
Authored: Mon Dec 1 17:11:05 2014 +0000
Committer: Richard Downer <ri...@apache.org>
Committed: Mon Dec 1 17:11:05 2014 +0000

----------------------------------------------------------------------
 .../entity/rebind/RebindCatalogEntityTest.java  |   6 +-
 .../management/osgi/OsgiStandaloneTest.java     |  30 ++--
 .../osgi/OsgiVersionMoreEntityTest.java         |  21 +++
 .../test/java/brooklyn/test/HttpService.java    |   5 +-
 .../entity/rebind/brooklyn-AppInCatalog.txt     |   5 +-
 .../osgi/brooklyn-osgi-test-a_0.1.0.txt         |   5 +-
 .../osgi/brooklyn-test-osgi-entities.txt        |   5 +
 .../brooklyn-test-osgi-more-entities_0.1.0.txt  |   5 +
 .../brooklyn-test-osgi-more-entities_0.2.0.txt  |   5 +
 ...-test-osgi-more-entities_evil-twin_0.2.0.txt |   5 +
 .../cassandra/cassandra-multicloud-snitch.txt   |   6 +-
 .../entity/osgi/karaf/KarafContainerTest.java   |  10 +-
 .../osgi/src/test/resources/hello-world.txt     |   5 +-
 .../nginx/NginxClusterIntegrationTest.java      |  12 +-
 .../nginx/NginxHttpsSslIntegrationTest.java     |  12 +-
 .../proxy/nginx/NginxIntegrationTest.java       |  18 ++-
 .../proxy/nginx/NginxLightIntegrationTest.java  |   3 -
 .../proxy/nginx/NginxRebindIntegrationTest.java |  12 +-
 .../nginx/NginxRebindWithHaIntegrationTest.java |  12 +-
 .../nginx/NginxUrlMappingIntegrationTest.java   |  41 +++---
 .../proxy/nginx/NginxWebClusterEc2LiveTest.java |   8 +-
 .../AbstractWebAppFixtureIntegrationTest.java   |   2 +
 ...lledDynamicWebAppClusterIntegrationTest.java |  22 +--
 .../ControlledDynamicWebAppClusterTest.java     |  17 ++-
 ...ElasticJavaWebAppServiceIntegrationTest.java |   8 +-
 ...namicWebAppClusterRebindIntegrationTest.java |  13 +-
 ...namicWebAppClusterRebindIntegrationTest.java |  12 +-
 .../jboss/JBoss6ServerAwsEc2LiveTest.java       |  10 +-
 ...Boss6ServerNonInheritingIntegrationTest.java |  11 +-
 .../jboss/JBoss7ServerAwsEc2LiveTest.java       |  12 +-
 .../jboss/JBoss7ServerDockerLiveTest.java       |   8 +-
 ...Boss7ServerNonInheritingIntegrationTest.java |  17 +--
 .../JBoss7ServerRebindingIntegrationTest.java   |  14 +-
 .../Jboss7ServerGoogleComputeLiveTest.java      |  12 +-
 .../webapp/tomcat/TomcatServerEc2LiveTest.java  |  12 +-
 .../tomcat/TomcatServerSoftlayerLiveTest.java   |  12 +-
 ...omcatServerWebAppFixtureIntegrationTest.java |   2 +
 .../brooklyn/launcher/WebAppRunnerTest.java     |   9 +-
 .../test/TestResourceUnavailableException.java  | 140 +++++++++++++++++++
 39 files changed, 425 insertions(+), 139 deletions(-)
----------------------------------------------------------------------



[2/4] incubator-brooklyn git commit: Add TestResourceUnavailableException

Posted by ri...@apache.org.
Add TestResourceUnavailableException

Provides a way to skip TestNG tests if a test resource is not available (such as in the source distribution, which does not carry binary test resources)


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/824dc156
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/824dc156
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/824dc156

Branch: refs/heads/master
Commit: 824dc156cbf6bf95e1e1f0b3cca8e6c1725e95df
Parents: 4b11fea
Author: Richard Downer <ri...@apache.org>
Authored: Wed Nov 26 13:05:44 2014 +0000
Committer: Richard Downer <ri...@apache.org>
Committed: Mon Dec 1 17:04:35 2014 +0000

----------------------------------------------------------------------
 .../test/TestResourceUnavailableException.java  | 140 +++++++++++++++++++
 1 file changed, 140 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/824dc156/utils/test-support/src/main/java/brooklyn/test/TestResourceUnavailableException.java
----------------------------------------------------------------------
diff --git a/utils/test-support/src/main/java/brooklyn/test/TestResourceUnavailableException.java b/utils/test-support/src/main/java/brooklyn/test/TestResourceUnavailableException.java
new file mode 100644
index 0000000..0738184
--- /dev/null
+++ b/utils/test-support/src/main/java/brooklyn/test/TestResourceUnavailableException.java
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package brooklyn.test;
+
+import com.google.common.base.Throwables;
+import org.testng.SkipException;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Indicates that a test cannot be run as a necessary resource is not available.
+ *
+ * <p>This exception should be used by tests that need a particular test resource (i.e., a file that is conventionally
+ * in the <code>src/test/resources</code> folder, and that available as a classpath resource at runtime) is not
+ * available. It will cause TestNG to mark the test as "skipped" with a suitable message.</p>
+ *
+ * <p>Some tests require binary files (such as OSGi bundles) which under Apache conventions are not able to be
+ * distributed in our source code release. This exception allows such tests to become "optional" so that they do not
+ * cause test failures when running the tests on a source distribution.</p>
+ *
+ * <p>Note that the single-string constructors expect the string to be the simple name of the classpath resource that
+ * is not available. The exception message is then derived from this. The two-string constructors take both the
+ * resource name and an explicit exception message.</p>
+ */
+@SuppressWarnings("UnusedDeclaration")
+public class TestResourceUnavailableException extends SkipException {
+
+    private final String resourceName;
+
+    /**
+     * Asserts that a resource is available on the classpath; otherwise, throws {@link TestResourceUnavailableException}
+     *
+     * Note that this will use the same classloader that was used to load this class.
+     *
+     * @param resourceName the classpath resource name, e.g.
+     *                     <code>/brooklyn/osgi/brooklyn-test-osgi-entities.jar</code>
+     */
+    public static void throwIfResourceUnavailable(Class<?> relativeToClass, String resourceName) {
+        checkNotNull(relativeToClass, relativeToClass);
+        checkNotNull(resourceName, "resourceName");
+        checkArgument(!resourceName.isEmpty(), "resourceName must not be empty");
+        InputStream resource = relativeToClass.getResourceAsStream(resourceName);
+        if (resource == null)
+            throw new TestResourceUnavailableException(resourceName);
+
+        // just make sure we clean up the resource
+        try {
+            resource.close();
+        } catch (IOException e) {
+            Throwables.propagate(e);
+        }
+    }
+
+    /**
+     * Instantiate an exception, giving the name of the unavailable resource.
+     *
+     * @param resourceName the name of the resource on the classpath, e.g.
+     *                     <code>/brooklyn/osgi/brooklyn-test-osgi-entities.jar</code>
+     */
+    public TestResourceUnavailableException(String resourceName) {
+        super(messageFromResourceName(resourceName));
+        this.resourceName = resourceName;
+    }
+
+    /**
+     * Instantiate an exception, giving the name of the unavailable resource.
+     *
+     * @param resourceName the name of the resource on the classpath, e.g.
+     *                     <code>/brooklyn/osgi/brooklyn-test-osgi-entities.jar</code>
+     * @param cause the underlying exception that caused this one
+     */
+    public TestResourceUnavailableException(String resourceName, Throwable cause) {
+        super(messageFromResourceName(resourceName), cause);
+        this.resourceName = resourceName;
+    }
+
+    /**
+     * Instantiate an exception, giving the name of the unavailable resource.
+     *
+     * @param resourceName the name of the resource on the classpath, e.g.
+     *                     <code>/brooklyn/osgi/brooklyn-test-osgi-entities.jar</code>
+     * @param skipMessage the message associated with the exception
+     */
+    public TestResourceUnavailableException(String resourceName, String skipMessage) {
+        super(skipMessage);
+        this.resourceName = resourceName;
+    }
+
+    /**
+     * Instantiate an exception, giving the name of the unavailable resource.
+     *
+     * @param resourceName the name of the resource on the classpath, e.g.
+     *                     <code>/brooklyn/osgi/brooklyn-test-osgi-entities.jar</code>
+     * @param skipMessage the message associated with the exception
+     * @param cause the underlying exception that caused this one
+     */
+    public TestResourceUnavailableException(String resourceName, String skipMessage, Throwable cause) {
+        super(skipMessage, cause);
+        this.resourceName = resourceName;
+    }
+
+    private static String messageFromResourceName(String resourceName) {
+        return String.format("Test resource '%s' not found; test skipped.", resourceName);
+    }
+
+    /**
+     * Get the name of the classpath resource that could not be loaded.
+     *
+     * @return the name of the classpath resource whose absence caused this exception.
+     */
+    public String getResourceName() {
+        return resourceName;
+    }
+
+    @Override
+    public boolean isSkip() {
+        return true;
+    }
+
+}


[3/4] incubator-brooklyn git commit: Make embedded wars optional

Posted by ri...@apache.org.
Make embedded wars optional

Modifies code that relies on war files as an embedded resource to
gracefully handle cases where the files are missing. Limited to tests,
which will cause TestNG to skip the test if the resource is missing.
Required for our source distribution, as Apache convention is to not
ship binaries in releases.


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

Branch: refs/heads/master
Commit: dc90382209f0709117ba7b2070b667b233c496ff
Parents: 7e5360d
Author: Richard Downer <ri...@apache.org>
Authored: Wed Nov 26 16:22:56 2014 +0000
Committer: Richard Downer <ri...@apache.org>
Committed: Mon Dec 1 17:05:55 2014 +0000

----------------------------------------------------------------------
 .../test/java/brooklyn/test/HttpService.java    |  5 ++-
 .../nginx/NginxClusterIntegrationTest.java      | 12 ++++--
 .../nginx/NginxHttpsSslIntegrationTest.java     | 12 ++++--
 .../proxy/nginx/NginxIntegrationTest.java       | 18 +++++----
 .../proxy/nginx/NginxLightIntegrationTest.java  |  3 --
 .../proxy/nginx/NginxRebindIntegrationTest.java | 12 ++++--
 .../nginx/NginxRebindWithHaIntegrationTest.java | 12 ++++--
 .../nginx/NginxUrlMappingIntegrationTest.java   | 41 +++++++++-----------
 .../proxy/nginx/NginxWebClusterEc2LiveTest.java |  8 ++--
 .../AbstractWebAppFixtureIntegrationTest.java   |  2 +
 ...lledDynamicWebAppClusterIntegrationTest.java | 22 ++++++-----
 .../ControlledDynamicWebAppClusterTest.java     | 17 ++++----
 ...ElasticJavaWebAppServiceIntegrationTest.java |  8 +++-
 ...namicWebAppClusterRebindIntegrationTest.java | 13 ++++---
 ...namicWebAppClusterRebindIntegrationTest.java | 12 +++---
 .../jboss/JBoss6ServerAwsEc2LiveTest.java       | 10 +++--
 ...Boss6ServerNonInheritingIntegrationTest.java | 11 ++++--
 .../jboss/JBoss7ServerAwsEc2LiveTest.java       | 12 ++++--
 .../jboss/JBoss7ServerDockerLiveTest.java       |  8 +++-
 ...Boss7ServerNonInheritingIntegrationTest.java | 17 ++++----
 .../JBoss7ServerRebindingIntegrationTest.java   | 14 ++++---
 .../Jboss7ServerGoogleComputeLiveTest.java      | 12 ++++--
 .../webapp/tomcat/TomcatServerEc2LiveTest.java  | 12 ++++--
 .../tomcat/TomcatServerSoftlayerLiveTest.java   | 12 ++++--
 ...omcatServerWebAppFixtureIntegrationTest.java |  2 +
 .../brooklyn/launcher/WebAppRunnerTest.java     |  9 ++++-
 26 files changed, 195 insertions(+), 121 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dc903822/core/src/test/java/brooklyn/test/HttpService.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/test/HttpService.java b/core/src/test/java/brooklyn/test/HttpService.java
index aa9a338..2dd8849 100644
--- a/core/src/test/java/brooklyn/test/HttpService.java
+++ b/core/src/test/java/brooklyn/test/HttpService.java
@@ -60,7 +60,8 @@ public class HttpService {
 
     private static final Logger log = LoggerFactory.getLogger(HttpService.class);
 
-    public static final String ROOT_WAR_URL = "classpath://hello-world.war";
+    public static final String ROOT_WAR_PATH = "/hello-world.war";
+    public static final String ROOT_WAR_URL = "classpath:" + ROOT_WAR_PATH;
     public static final String SERVER_KEYSTORE = "classpath://server.ks";
     
     private final boolean httpsEnabled;
@@ -109,6 +110,8 @@ public class HttpService {
     }
 
     public HttpService start() throws Exception {
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), ROOT_WAR_PATH);
+
         try {
             if (httpsEnabled) {
                 //by default the server is configured with a http connector, this needs to be removed since we are going

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dc903822/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxClusterIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxClusterIntegrationTest.java b/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxClusterIntegrationTest.java
index bf653f1..31c3a4b 100644
--- a/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxClusterIntegrationTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxClusterIntegrationTest.java
@@ -24,6 +24,7 @@ import static org.testng.Assert.assertTrue;
 import java.util.Collections;
 import java.util.List;
 
+import brooklyn.test.TestResourceUnavailableException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.annotations.BeforeMethod;
@@ -62,7 +63,6 @@ public class NginxClusterIntegrationTest extends BrooklynAppLiveTestSupport {
 
     private static final long TIMEOUT_MS = 60*1000;
     
-    private String war;
     private Location localhostProvisioningLoc;
     private EntityManager entityManager;
     private LoadBalancerCluster loadBalancerCluster;
@@ -73,7 +73,6 @@ public class NginxClusterIntegrationTest extends BrooklynAppLiveTestSupport {
     @Override
     public void setUp() throws Exception {
         super.setUp();
-        war = "classpath://hello-world.war";
         localhostProvisioningLoc = app.newLocalhostProvisioningLocation();
         
         urlMappings = app.createAndManageChild(EntitySpec.create(BasicGroup.class)
@@ -83,6 +82,11 @@ public class NginxClusterIntegrationTest extends BrooklynAppLiveTestSupport {
         nginxSpec = EntitySpec.create(NginxController.class);
     }
 
+    public String getTestWar() {
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war");
+        return "classpath://hello-world.war";
+    }
+
     @Test(groups = "Integration")
     public void testCreatesNginxInstancesAndResizes() {
         loadBalancerCluster = app.createAndManageChild(EntitySpec.create(LoadBalancerCluster.class)
@@ -107,7 +111,7 @@ public class NginxClusterIntegrationTest extends BrooklynAppLiveTestSupport {
         DynamicCluster serverPool = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
                 .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(JBoss7Server.class))
                 .configure("initialSize", 1)
-                .configure(JavaWebAppService.ROOT_WAR, war.toString()));
+                .configure(JavaWebAppService.ROOT_WAR, getTestWar()));
         
         loadBalancerCluster = app.createAndManageChild(EntitySpec.create(LoadBalancerCluster.class)
                 .configure("serverPool", serverPool)
@@ -129,7 +133,7 @@ public class NginxClusterIntegrationTest extends BrooklynAppLiveTestSupport {
         DynamicCluster c1 = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
                 .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(JBoss7Server.class))
                 .configure("initialSize", 1)
-                .configure(JavaWebAppService.NAMED_WARS, ImmutableList.of(war)));
+                .configure(JavaWebAppService.NAMED_WARS, ImmutableList.of(getTestWar())));
 
         UrlMapping urlMapping = entityManager.createEntity(EntitySpec.create(UrlMapping.class)
                 .configure("domain", "localhost")

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dc903822/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxHttpsSslIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxHttpsSslIntegrationTest.java b/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxHttpsSslIntegrationTest.java
index 826bd0f..8ba88b7 100644
--- a/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxHttpsSslIntegrationTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxHttpsSslIntegrationTest.java
@@ -23,6 +23,7 @@ import static org.testng.Assert.assertTrue;
 
 import java.io.File;
 
+import brooklyn.test.TestResourceUnavailableException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.Assert;
@@ -41,7 +42,6 @@ import brooklyn.entity.webapp.jboss.JBoss7Server;
 import brooklyn.location.Location;
 import brooklyn.test.Asserts;
 import brooklyn.test.HttpTestUtils;
-import brooklyn.test.entity.TestApplication;
 
 import com.google.common.collect.ImmutableList;
 
@@ -56,7 +56,6 @@ public class NginxHttpsSslIntegrationTest extends BrooklynAppLiveTestSupport {
     private DynamicCluster cluster;
     private Location localLoc;
 
-    private static final String WAR_URL = "classpath://hello-world.war";
     private static final String CERTIFICATE_URL = "classpath://ssl/certs/localhost/server.crt";
     private static final String KEY_URL = "classpath://ssl/certs/localhost/server.key";
     
@@ -67,6 +66,11 @@ public class NginxHttpsSslIntegrationTest extends BrooklynAppLiveTestSupport {
         localLoc = mgmt.getLocationRegistry().resolve("localhost");
     }
 
+    public String getTestWar() {
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war");
+        return "classpath://hello-world.war";
+    }
+
     /**
      * Test that the Nginx proxy starts up and sets SERVICE_UP correctly.
      */
@@ -75,7 +79,7 @@ public class NginxHttpsSslIntegrationTest extends BrooklynAppLiveTestSupport {
         cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
             .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(JBoss7Server.class))
             .configure("initialSize", 1)
-            .configure(JavaWebAppService.ROOT_WAR, WAR_URL));
+            .configure(JavaWebAppService.ROOT_WAR, getTestWar()));
         
         ProxySslConfig ssl = ProxySslConfig.builder()
                 .certificateSourceUrl(CERTIFICATE_URL)
@@ -132,7 +136,7 @@ public class NginxHttpsSslIntegrationTest extends BrooklynAppLiveTestSupport {
         cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
             .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(JBoss7Server.class))
             .configure("initialSize", 1)
-            .configure(JavaWebAppService.ROOT_WAR, WAR_URL));
+            .configure(JavaWebAppService.ROOT_WAR, getTestWar()));
         
         ProxySslConfig ssl = ProxySslConfig.builder()
                 .certificateDestination(getFile("ssl/certs/localhost/server.crt"))

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dc903822/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxIntegrationTest.java b/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxIntegrationTest.java
index 2dd5567..74d6dcf 100644
--- a/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxIntegrationTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxIntegrationTest.java
@@ -27,6 +27,7 @@ import static org.testng.Assert.assertTrue;
 
 import java.util.Map;
 
+import brooklyn.test.TestResourceUnavailableException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.annotations.BeforeMethod;
@@ -56,8 +57,6 @@ import com.google.common.collect.Iterables;
 public class NginxIntegrationTest extends BrooklynAppLiveTestSupport {
     private static final Logger log = LoggerFactory.getLogger(NginxIntegrationTest.class);
 
-    static final String HELLO_WAR_URL = "classpath://hello-world.war";
-
     private NginxController nginx;
     private DynamicCluster serverPool;
     private Location localLoc;
@@ -69,6 +68,11 @@ public class NginxIntegrationTest extends BrooklynAppLiveTestSupport {
         localLoc = mgmt.getLocationRegistry().resolve("localhost");
     }
 
+    public String getTestWar() {
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war");
+        return "classpath://hello-world.war";
+    }
+
     /**
      * Test that the Nginx proxy starts up and sets SERVICE_UP correctly.
      */
@@ -120,7 +124,7 @@ public class NginxIntegrationTest extends BrooklynAppLiveTestSupport {
         serverPool = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
                 .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(JBoss7Server.class))
                 .configure("initialSize", 1)
-                .configure(JavaWebAppService.ROOT_WAR, HELLO_WAR_URL));
+                .configure(JavaWebAppService.ROOT_WAR, getTestWar()));
         
         nginx = app.createAndManageChild(EntitySpec.create(NginxController.class)
                 .configure("serverPool", serverPool)
@@ -162,7 +166,7 @@ public class NginxIntegrationTest extends BrooklynAppLiveTestSupport {
         serverPool = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
                 .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(JBoss7Server.class))
                 .configure("initialSize", 1)
-                .configure(JavaWebAppService.ROOT_WAR, HELLO_WAR_URL));
+                .configure(JavaWebAppService.ROOT_WAR, getTestWar()));
 
         nginx = app.createAndManageChild(EntitySpec.create(NginxController.class)
                 .configure("serverPool", serverPool)
@@ -205,7 +209,7 @@ public class NginxIntegrationTest extends BrooklynAppLiveTestSupport {
         serverPool = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
                 .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(JBoss7Server.class))
                 .configure("initialSize", 1)
-                .configure(JavaWebAppService.ROOT_WAR, HELLO_WAR_URL));
+                .configure(JavaWebAppService.ROOT_WAR, getTestWar()));
         
         nginx = app.createAndManageChild(EntitySpec.create(NginxController.class)
                 .configure("serverPool", serverPool)
@@ -281,7 +285,7 @@ public class NginxIntegrationTest extends BrooklynAppLiveTestSupport {
         serverPool = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
                 .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(JBoss7Server.class))
                 .configure("initialSize", 1)
-                .configure(JavaWebAppService.ROOT_WAR, HELLO_WAR_URL));
+                .configure(JavaWebAppService.ROOT_WAR, getTestWar()));
         
         nginx = app.createAndManageChild(EntitySpec.create(NginxController.class)
                 .configure("serverPool", serverPool));
@@ -341,7 +345,7 @@ public class NginxIntegrationTest extends BrooklynAppLiveTestSupport {
         serverPool = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
                 .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(JBoss7Server.class))
                 .configure("initialSize", 1)
-                .configure(JavaWebAppService.ROOT_WAR, HELLO_WAR_URL));
+                .configure(JavaWebAppService.ROOT_WAR, getTestWar()));
         
         nginx = app.createAndManageChild(EntitySpec.create(NginxController.class)
                 .configure("serverPool", serverPool));

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dc903822/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxLightIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxLightIntegrationTest.java b/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxLightIntegrationTest.java
index 4605735..b55e598 100644
--- a/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxLightIntegrationTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxLightIntegrationTest.java
@@ -44,9 +44,6 @@ public class NginxLightIntegrationTest extends BrooklynAppUnitTestSupport {
     private NginxController nginx;
     private DynamicCluster cluster;
 
-    private URL war;
-    private static final String WAR_URL = "classpath://hello-world.war";
-    
     // FIXME Fails because getting addEntity callback for group members while nginx is still starting,
     // so important nginx fields are still null. Therefore get NPE for cluster members, and thus targets
     // is of size zero.

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dc903822/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxRebindIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxRebindIntegrationTest.java b/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxRebindIntegrationTest.java
index 3556548..11ae4f2 100644
--- a/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxRebindIntegrationTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxRebindIntegrationTest.java
@@ -30,6 +30,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
+import brooklyn.test.TestResourceUnavailableException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.annotations.AfterMethod;
@@ -66,7 +67,6 @@ public class NginxRebindIntegrationTest extends RebindTestFixtureWithApp {
 
     private static final Logger LOG = LoggerFactory.getLogger(NginxRebindIntegrationTest.class);
 
-    private URL warUrl;
     private LocalhostMachineProvisioningLocation localhostProvisioningLocation;
     private List<WebAppMonitor> webAppMonitors = new CopyOnWriteArrayList<WebAppMonitor>();
     private ExecutorService executor;
@@ -82,11 +82,15 @@ public class NginxRebindIntegrationTest extends RebindTestFixtureWithApp {
     @BeforeMethod(alwaysRun=true)
     public void setUp() throws Exception {
         super.setUp();
-        warUrl = getClass().getClassLoader().getResource("hello-world.war");
         localhostProvisioningLocation = origManagementContext.getLocationManager().createLocation(LocationSpec.create(LocalhostMachineProvisioningLocation.class));
         executor = Executors.newCachedThreadPool();
     }
 
+    public String getTestWar() {
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war");
+        return "classpath://hello-world.war";
+    }
+
     @AfterMethod(alwaysRun=true)
     public void tearDown() throws Exception {
         for (WebAppMonitor monitor : webAppMonitors) {
@@ -157,7 +161,7 @@ public class NginxRebindIntegrationTest extends RebindTestFixtureWithApp {
         
         // Set up nginx with a server pool
         DynamicCluster origServerPool = origApp.createAndManageChild(EntitySpec.create(DynamicCluster.class)
-                .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(JBoss7Server.class).configure("war", warUrl.toString()))
+                .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(JBoss7Server.class).configure("war", getTestWar()))
                 .configure("initialSize", 1));
         
         NginxController origNginx = origApp.createAndManageChild(EntitySpec.create(NginxController.class)
@@ -230,7 +234,7 @@ public class NginxRebindIntegrationTest extends RebindTestFixtureWithApp {
                 .configure("childrenAsMembers", true));
         
         DynamicCluster origServerPool = origApp.createAndManageChild(EntitySpec.create(DynamicCluster.class)
-                .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(JBoss7Server.class).configure("war", warUrl.toString()))
+                .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(JBoss7Server.class).configure("war", getTestWar()))
                 .configure("initialSize", 1)); 
 
         UrlMapping origMapping = origApp.getManagementContext().getEntityManager().createEntity(EntitySpec.create(UrlMapping.class)

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dc903822/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxRebindWithHaIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxRebindWithHaIntegrationTest.java b/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxRebindWithHaIntegrationTest.java
index 6575d0b..6a32428 100644
--- a/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxRebindWithHaIntegrationTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxRebindWithHaIntegrationTest.java
@@ -26,6 +26,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
+import brooklyn.test.TestResourceUnavailableException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.Assert;
@@ -69,7 +70,6 @@ public class NginxRebindWithHaIntegrationTest extends RebindTestFixtureWithApp {
 
     private static final Logger LOG = LoggerFactory.getLogger(NginxRebindWithHaIntegrationTest.class);
 
-    private URL warUrl;
     private List<WebAppMonitor> webAppMonitors = new CopyOnWriteArrayList<WebAppMonitor>();
     private ExecutorService executor;
     private LocalhostMachineProvisioningLocation loc;
@@ -83,11 +83,15 @@ public class NginxRebindWithHaIntegrationTest extends RebindTestFixtureWithApp {
         // to set things like correct Java on path.
         return true;
     }
-    
+
+    public String getTestWar() {
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war");
+        return "classpath://hello-world.war";
+    }
+
     @BeforeMethod(alwaysRun=true)
     public void setUp() throws Exception {
         super.setUp();
-        warUrl = getClass().getClassLoader().getResource("hello-world.war");
         loc = origManagementContext.getLocationManager().createLocation(LocationSpec.create(LocalhostMachineProvisioningLocation.class)
             .configure("address", Networking.getLocalHost())
             .configure(SshTool.PROP_TOOL_CLASS, RecordingSshjTool.class.getName()));
@@ -123,7 +127,7 @@ public class NginxRebindWithHaIntegrationTest extends RebindTestFixtureWithApp {
     @Test(groups = "Integration")
     public void testChangeModeFailureStopsTasksButHappyUponResumption() throws Exception {
         DynamicCluster origServerPool = origApp.createAndManageChild(EntitySpec.create(DynamicCluster.class)
-                .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(TomcatServer.class).configure("war", warUrl.toString()))
+                .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(TomcatServer.class).configure("war", getTestWar()))
                 .configure("initialSize", 1));
         
         NginxController origNginx = origApp.createAndManageChild(EntitySpec.create(NginxController.class)

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dc903822/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxUrlMappingIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxUrlMappingIntegrationTest.java b/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxUrlMappingIntegrationTest.java
index 2ed881e..d1f2fcb 100644
--- a/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxUrlMappingIntegrationTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxUrlMappingIntegrationTest.java
@@ -19,19 +19,18 @@
 package brooklyn.entity.proxy.nginx;
 
 import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
 import static org.testng.Assert.assertTrue;
 import static org.testng.Assert.fail;
 
 import java.net.Inet4Address;
 import java.net.InetAddress;
-import java.net.URL;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import brooklyn.test.TestResourceUnavailableException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.annotations.BeforeMethod;
@@ -71,23 +70,16 @@ public class NginxUrlMappingIntegrationTest extends BrooklynAppLiveTestSupport {
     
     private static final Logger log = LoggerFactory.getLogger(NginxUrlMappingIntegrationTest.class);
 
-    private static final String WAR_URL = "classpath://hello-world.war";
-    
     private NginxController nginx;
-    private DynamicCluster cluster;
     private Group urlMappingsGroup;
     private EntityManager entityManager;
     private LocalhostMachineProvisioningLocation localLoc;
     
-    private URL war;
-
     @BeforeMethod(alwaysRun=true)
     @Override
     public void setUp() throws Exception {
         super.setUp();
-        war = getClass().getClassLoader().getResource("hello-world.war");
-        assertNotNull(war, "Unable to locate hello-world.war resource");
-        
+
         urlMappingsGroup = app.createAndManageChild(EntitySpec.create(BasicGroup.class)
                 .configure("childrenAsMembers", true));
         entityManager = app.getManagementContext().getEntityManager();
@@ -95,6 +87,11 @@ public class NginxUrlMappingIntegrationTest extends BrooklynAppLiveTestSupport {
         localLoc = new LocalhostMachineProvisioningLocation();
     }
 
+    public String getTestWar() {
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war");
+        return "classpath://hello-world.war";
+    }
+
     protected void checkExtraLocalhosts() throws Exception {
         Set<String> failedHosts = Sets.newLinkedHashSet();
         List<String> allHosts = ImmutableList.of("localhost", "localhost1", "localhost2", "localhost3", "localhost4");
@@ -125,7 +122,7 @@ public class NginxUrlMappingIntegrationTest extends BrooklynAppLiveTestSupport {
         DynamicCluster c0 = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
                 .configure("initialSize", 1)
                 .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(JBoss7Server.class).configure("httpPort", "8100+"))
-                .configure(JavaWebAppService.ROOT_WAR, WAR_URL));
+                .configure(JavaWebAppService.ROOT_WAR, getTestWar()));
         UrlMapping u0 = entityManager.createEntity(EntitySpec.create(UrlMapping.class)
                 .configure("domain", "localhost1")
                 .configure("target", c0)
@@ -136,7 +133,7 @@ public class NginxUrlMappingIntegrationTest extends BrooklynAppLiveTestSupport {
         DynamicCluster c1 = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
                 .configure("initialSize", 1)
                 .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(JBoss7Server.class).configure("httpPort", "8100+"))
-                .configure(JavaWebAppService.NAMED_WARS, ImmutableList.of(WAR_URL)));
+                .configure(JavaWebAppService.NAMED_WARS, ImmutableList.of(getTestWar())));
         UrlMapping u1 = entityManager.createEntity(EntitySpec.create(UrlMapping.class)
                 .configure("domain", "localhost2")
                 .configure("path", "/hello-world($|/.*)")
@@ -160,7 +157,7 @@ public class NginxUrlMappingIntegrationTest extends BrooklynAppLiveTestSupport {
         app.start(ImmutableList.of(localLoc));
         final int port = nginx.getAttribute(NginxController.PROXY_HTTP_PORT);
         for (Entity member : c2.getMembers()) {
-            ((JBoss7Server)member).deploy(war.toString(), "c2.war");
+            ((JBoss7Server)member).deploy(getTestWar(), "c2.war");
         }
     
         Entities.dumpInfo(app);
@@ -236,10 +233,10 @@ public class NginxUrlMappingIntegrationTest extends BrooklynAppLiveTestSupport {
         final int port = nginx.getAttribute(NginxController.PROXY_HTTP_PORT);
         
         for (Entity child : c0.getMembers()) {
-            ((JBoss7Server)child).deploy(war.toString(), "atC0.war");
+            ((JBoss7Server)child).deploy(getTestWar(), "atC0.war");
         }
         for (Entity child : c1.getMembers()) {
-            ((JBoss7Server)child).deploy(war.toString(), "atC1.war");
+            ((JBoss7Server)child).deploy(getTestWar(), "atC1.war");
         }
 
         // Confirm routes requests to the correct cluster
@@ -262,7 +259,7 @@ public class NginxUrlMappingIntegrationTest extends BrooklynAppLiveTestSupport {
         DynamicCluster c0 = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
                 .configure("initialSize", 1)
                 .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(JBoss7Server.class).configure("httpPort", "8100+"))
-                .configure(JavaWebAppService.ROOT_WAR, war.toString()));
+                .configure(JavaWebAppService.ROOT_WAR, getTestWar()));
         UrlMapping u0 = entityManager.createEntity(EntitySpec.create(UrlMapping.class)
                 .configure("domain", "localhost2")
                 .configure("target", c0)
@@ -296,12 +293,12 @@ public class NginxUrlMappingIntegrationTest extends BrooklynAppLiveTestSupport {
         DynamicCluster coreCluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
                 .configure("initialSize", 1)
                 .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(JBoss7Server.class).configure("httpPort", "8100+"))
-                .configure(JavaWebAppService.ROOT_WAR, war.toString()));
+                .configure(JavaWebAppService.ROOT_WAR, getTestWar()));
         
         DynamicCluster c1 = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
                 .configure("initialSize", 1)
                 .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(JBoss7Server.class).configure("httpPort", "8100+"))
-                .configure(JavaWebAppService.NAMED_WARS, ImmutableList.of(war.toString())));
+                .configure(JavaWebAppService.NAMED_WARS, ImmutableList.of(getTestWar())));
         UrlMapping u1 = entityManager.createEntity(EntitySpec.create(UrlMapping.class)
                 .configure("domain", "localhost1")
                 .configure("target", c1)
@@ -338,7 +335,7 @@ public class NginxUrlMappingIntegrationTest extends BrooklynAppLiveTestSupport {
         DynamicCluster c0 = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
                 .configure("initialSize", 1)
                 .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(JBoss7Server.class).configure("httpPort", "8100+"))
-                .configure(JavaWebAppService.ROOT_WAR, WAR_URL));
+                .configure(JavaWebAppService.ROOT_WAR, getTestWar()));
         UrlMapping u0 = entityManager.createEntity(EntitySpec.create(UrlMapping.class)
                 .configure("domain", "localhost1")
                 .configure("target", c0)
@@ -391,7 +388,7 @@ public class NginxUrlMappingIntegrationTest extends BrooklynAppLiveTestSupport {
         final DynamicCluster c1 = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
                 .configure("initialSize", 1)
                 .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(JBoss7Server.class).configure("httpPort", "8100+"))
-                .configure(JavaWebAppService.ROOT_WAR, war.toString()));
+                .configure(JavaWebAppService.ROOT_WAR, getTestWar()));
         final UrlMapping u1 = entityManager.createEntity(EntitySpec.create(UrlMapping.class)
                 .configure("domain", "localhost1")
                 .configure("target", c1)
@@ -474,7 +471,7 @@ public class NginxUrlMappingIntegrationTest extends BrooklynAppLiveTestSupport {
         final int port = nginx.getAttribute(NginxController.PROXY_HTTP_PORT);
         
         for (Entity child : c0.getMembers()) {
-            ((JBoss7Server)child).deploy(war.toString(), "atC0.war");
+            ((JBoss7Server)child).deploy(getTestWar(), "atC0.war");
         }
 
         // Confirm routes requests to the correct cluster
@@ -497,7 +494,7 @@ public class NginxUrlMappingIntegrationTest extends BrooklynAppLiveTestSupport {
         DynamicCluster c0 = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
                 .configure("initialSize", 1)
                 .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(JBoss7Server.class).configure("httpPort", "8100+"))
-                .configure(JavaWebAppService.ROOT_WAR, WAR_URL));
+                .configure(JavaWebAppService.ROOT_WAR, getTestWar()));
         UrlMapping u0 = entityManager.createEntity(EntitySpec.create(UrlMapping.class)
                 .configure("domain", "localhost1")
                 .configure("target", c0)

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dc903822/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxWebClusterEc2LiveTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxWebClusterEc2LiveTest.java b/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxWebClusterEc2LiveTest.java
index 12df430..2e90749 100644
--- a/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxWebClusterEc2LiveTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxWebClusterEc2LiveTest.java
@@ -22,6 +22,7 @@ import static org.testng.Assert.assertNotNull;
 
 import java.net.URL;
 
+import brooklyn.test.TestResourceUnavailableException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.annotations.AfterMethod;
@@ -74,11 +75,12 @@ public class NginxWebClusterEc2LiveTest {
     public void shutdown() {
         if (app != null) Entities.destroyAll(app.getManagementContext());
     }
-    
+
     @Test(groups = "Live")
     public void testProvisionAwsCluster() {
-        String warName = "hello-world.war";
-        URL war = getClass().getClassLoader().getResource(warName);
+        String warName = "/hello-world.war";
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), warName);
+        URL war = getClass().getResource(warName);
         assertNotNull(war, "Unable to locate resource "+warName);
         
         cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dc903822/software/webapp/src/test/java/brooklyn/entity/webapp/AbstractWebAppFixtureIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/AbstractWebAppFixtureIntegrationTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/AbstractWebAppFixtureIntegrationTest.java
index 8704379..3811849 100644
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/AbstractWebAppFixtureIntegrationTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/webapp/AbstractWebAppFixtureIntegrationTest.java
@@ -37,6 +37,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import brooklyn.test.TestResourceUnavailableException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.annotations.AfterClass;
@@ -405,6 +406,7 @@ public abstract class AbstractWebAppFixtureIntegrationTest {
      */
     @DataProvider(name = "entitiesWithWarAndURL")
     public Object[][] entitiesWithWar() {
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world-no-mapping.war");
         List<Object[]> result = Lists.newArrayList();
         
         for (Object[] entity : basicEntities()) {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dc903822/software/webapp/src/test/java/brooklyn/entity/webapp/ControlledDynamicWebAppClusterIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/ControlledDynamicWebAppClusterIntegrationTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/ControlledDynamicWebAppClusterIntegrationTest.java
index 4d97b40..ad19b6b 100644
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/ControlledDynamicWebAppClusterIntegrationTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/webapp/ControlledDynamicWebAppClusterIntegrationTest.java
@@ -21,10 +21,10 @@ package brooklyn.entity.webapp;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertNotNull;
 
-import java.net.URL;
 import java.util.List;
 import java.util.concurrent.Callable;
 
+import brooklyn.test.TestResourceUnavailableException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.annotations.BeforeMethod;
@@ -58,25 +58,27 @@ public class ControlledDynamicWebAppClusterIntegrationTest extends BrooklynAppLi
 
     private static final int TIMEOUT_MS = 10*1000;
     
-    private URL warUrl;
     private LocalhostMachineProvisioningLocation loc;
     private List<LocalhostMachineProvisioningLocation> locs;
     
     @BeforeMethod(alwaysRun=true)
     public void setUp() throws Exception {
         super.setUp();
-        String warPath = "hello-world.war";
-        warUrl = getClass().getClassLoader().getResource(warPath);
-        
+
         loc = app.newLocalhostProvisioningLocation();
         locs = ImmutableList.of(loc);
     }
-    
+
+    public String getTestWar() {
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war");
+        return "classpath://hello-world.war";
+    }
+
     @Test(groups="Integration")
     public void testConfiguresController() {
         ControlledDynamicWebAppCluster cluster = app.createAndManageChild(EntitySpec.create(ControlledDynamicWebAppCluster.class)
                 .configure("initialSize", 1)
-                .configure("memberSpec", EntitySpec.create(JBoss7Server.class).configure("war", warUrl.toString())));
+                .configure("memberSpec", EntitySpec.create(JBoss7Server.class).configure("war", getTestWar())));
         app.start(locs);
 
         String url = cluster.getController().getAttribute(NginxController.ROOT_URL);
@@ -88,7 +90,7 @@ public class ControlledDynamicWebAppClusterIntegrationTest extends BrooklynAppLi
     public void testSetsToplevelHostnameFromController() {
         ControlledDynamicWebAppCluster cluster = app.createAndManageChild(EntitySpec.create(ControlledDynamicWebAppCluster.class)
                 .configure("initialSize", 1)
-                .configure("memberSpec", EntitySpec.create(JBoss7Server.class).configure("war", warUrl.toString())));
+                .configure("memberSpec", EntitySpec.create(JBoss7Server.class).configure("war", getTestWar())));
         app.start(locs);
 
         String expectedHostname = cluster.getController().getAttribute(LoadBalancer.HOSTNAME);
@@ -108,7 +110,7 @@ public class ControlledDynamicWebAppClusterIntegrationTest extends BrooklynAppLi
         ControlledDynamicWebAppCluster cluster = app.createAndManageChild(EntitySpec.create(ControlledDynamicWebAppCluster.class)
                 .configure("initialSize", 1)
                 .configure(ControlledDynamicWebAppCluster.MEMBER_SPEC, EntitySpec.create(JBoss7Server.class)
-                        .configure(JBoss7Server.ROOT_WAR, warUrl.toString()))
+                        .configure(JBoss7Server.ROOT_WAR, getTestWar()))
                 .configure(ControlledDynamicWebAppCluster.WEB_CLUSTER_SPEC, EntitySpec.create(DynamicWebAppCluster.class)
                         .displayName("mydisplayname")));
         app.start(locs);
@@ -147,7 +149,7 @@ public class ControlledDynamicWebAppClusterIntegrationTest extends BrooklynAppLi
     public void testTomcatAbsoluteRedirect() {
         final ControlledDynamicWebAppCluster cluster = app.createAndManageChild(EntitySpec.create(ControlledDynamicWebAppCluster.class)
             .configure(ControlledDynamicWebAppCluster.MEMBER_SPEC, EntitySpec.create(TomcatServer.class)
-                    .configure(TomcatServer.ROOT_WAR, "classpath://hello-world.war"))
+            .configure(TomcatServer.ROOT_WAR, getTestWar()))
             .configure("initialSize", 1)
             .configure(AbstractController.SERVICE_UP_URL_PATH, "hello/redirectAbsolute")
         );

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dc903822/software/webapp/src/test/java/brooklyn/entity/webapp/ControlledDynamicWebAppClusterTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/ControlledDynamicWebAppClusterTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/ControlledDynamicWebAppClusterTest.java
index 54509b7..1fb0d84 100644
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/ControlledDynamicWebAppClusterTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/webapp/ControlledDynamicWebAppClusterTest.java
@@ -23,6 +23,7 @@ import static org.testng.Assert.assertEquals;
 import java.net.URL;
 import java.util.List;
 
+import brooklyn.test.TestResourceUnavailableException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.annotations.BeforeMethod;
@@ -51,20 +52,22 @@ import com.google.common.collect.Lists;
 public class ControlledDynamicWebAppClusterTest extends BrooklynAppUnitTestSupport {
     private static final Logger log = LoggerFactory.getLogger(ControlledDynamicWebAppClusterTest.class);
 
-    private URL warUrl;
     private LocalhostMachineProvisioningLocation loc;
     private List<LocalhostMachineProvisioningLocation> locs;
     
     @BeforeMethod(alwaysRun=true)
     public void setUp() throws Exception {
         super.setUp();
-        String warPath = "hello-world.war";
-        warUrl = getClass().getClassLoader().getResource(warPath);
-        
+
         loc = app.newLocalhostProvisioningLocation();
         locs = ImmutableList.of(loc);
     }
-    
+
+    public String getTestWar() {
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war");
+        return "classpath://hello-world.war";
+    }
+
     @Test
     public void testUsesCustomController() {
         AbstractController controller = app.createAndManageChild(EntitySpec.create(TrackingAbstractController.class).displayName("mycustom"));
@@ -72,7 +75,7 @@ public class ControlledDynamicWebAppClusterTest extends BrooklynAppUnitTestSuppo
         ControlledDynamicWebAppCluster cluster = app.createAndManageChild(EntitySpec.create(ControlledDynamicWebAppCluster.class)
                 .configure("initialSize", 0)
                 .configure(ControlledDynamicWebAppCluster.CONTROLLER, controller)
-                .configure("memberSpec", EntitySpec.create(JBoss7Server.class).configure("war", warUrl.toString())));
+                .configure("memberSpec", EntitySpec.create(JBoss7Server.class).configure("war", getTestWar())));
         app.start(locs);
 
         EntityTestUtils.assertAttributeEqualsEventually(controller, AbstractController.SERVICE_UP, true);
@@ -89,7 +92,7 @@ public class ControlledDynamicWebAppClusterTest extends BrooklynAppUnitTestSuppo
         ControlledDynamicWebAppCluster cluster = app.createAndManageChild(EntitySpec.create(ControlledDynamicWebAppCluster.class)
                 .configure("initialSize", 0)
                 .configure(ControlledDynamicWebAppCluster.CONTROLLER_SPEC, controllerSpec)
-                .configure("memberSpec", EntitySpec.create(JBoss7Server.class).configure("war", warUrl.toString())));
+                .configure("memberSpec", EntitySpec.create(JBoss7Server.class).configure("war", getTestWar())));
         app.start(locs);
         LoadBalancer controller = cluster.getController();
         

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dc903822/software/webapp/src/test/java/brooklyn/entity/webapp/ElasticJavaWebAppServiceIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/ElasticJavaWebAppServiceIntegrationTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/ElasticJavaWebAppServiceIntegrationTest.java
index 09535b7..5bfea3e 100644
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/ElasticJavaWebAppServiceIntegrationTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/webapp/ElasticJavaWebAppServiceIntegrationTest.java
@@ -18,6 +18,7 @@
  */
 package brooklyn.entity.webapp;
 
+import brooklyn.test.TestResourceUnavailableException;
 import org.testng.Assert;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
@@ -47,12 +48,17 @@ public class ElasticJavaWebAppServiceIntegrationTest {
         if (app != null) Entities.destroyAll(app.getManagementContext());
     }
 
+    public String getTestWar() {
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war");
+        return "classpath://hello-world.war";
+    }
+
     @SuppressWarnings("deprecation")
     @Test(groups = "Integration")
     // TODO a new approach to what ElasticJavaWebAppService.Factory does, giving a different entity depending on location!
     public void testLegacyFactory() {
         ElasticJavaWebAppService svc =
-            new ElasticJavaWebAppService.Factory().newEntity(MutableMap.of("war", "classpath://hello-world.war"), app);
+            new ElasticJavaWebAppService.Factory().newEntity(MutableMap.of("war", getTestWar()), app);
         Entities.manage(svc);
         app.start(ImmutableList.of(loc));
         

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dc903822/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/ControlledDynamicWebAppClusterRebindIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/ControlledDynamicWebAppClusterRebindIntegrationTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/ControlledDynamicWebAppClusterRebindIntegrationTest.java
index 777742e..ce45794 100644
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/ControlledDynamicWebAppClusterRebindIntegrationTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/ControlledDynamicWebAppClusterRebindIntegrationTest.java
@@ -21,16 +21,15 @@ package brooklyn.entity.webapp.jboss;
 import static brooklyn.test.EntityTestUtils.assertAttributeEqualsEventually;
 import static brooklyn.test.HttpTestUtils.assertHttpStatusCodeEquals;
 import static brooklyn.test.HttpTestUtils.assertHttpStatusCodeEventuallyEquals;
-import static com.google.common.base.Preconditions.checkNotNull;
 import static org.testng.Assert.assertEquals;
 
 import java.io.File;
-import java.net.URL;
 import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
+import brooklyn.test.TestResourceUnavailableException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.annotations.AfterMethod;
@@ -61,7 +60,6 @@ public class ControlledDynamicWebAppClusterRebindIntegrationTest {
     
     static { TimeExtras.init(); }
 
-    private URL warUrl;
     private LocalhostMachineProvisioningLocation localhostProvisioningLocation;
     private TestApplication origApp;
     private TestApplication newApp;
@@ -74,8 +72,6 @@ public class ControlledDynamicWebAppClusterRebindIntegrationTest {
     
     @BeforeMethod(alwaysRun=true)
     public void setUp() {
-        String warPath = "hello-world.war";
-        warUrl = checkNotNull(getClass().getClassLoader().getResource(warPath), "warUrl");
         executor = Executors.newCachedThreadPool();
 
         mementoDir = Files.createTempDir();
@@ -97,6 +93,11 @@ public class ControlledDynamicWebAppClusterRebindIntegrationTest {
         if (mementoDir != null) RebindTestUtils.deleteMementoDir(mementoDir);
     }
 
+    public String getTestWar() {
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war");
+        return "classpath://hello-world.war";
+    }
+
     private TestApplication rebind() throws Exception {
         RebindTestUtils.waitForPersisted(origApp);
         
@@ -120,7 +121,7 @@ public class ControlledDynamicWebAppClusterRebindIntegrationTest {
         NginxController origNginx = origApp.createAndManageChild(EntitySpec.create(NginxController.class).configure("domain", "localhost"));
 
         origApp.createAndManageChild(EntitySpec.create(ControlledDynamicWebAppCluster.class)
-                .configure("memberSpec", EntitySpec.create(JBoss7Server.class).configure("war", warUrl.toString()))
+                .configure("memberSpec", EntitySpec.create(JBoss7Server.class).configure("war", getTestWar()))
                 .configure("initialSize", 1)
                 .configure("controller", origNginx));
         

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dc903822/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/DynamicWebAppClusterRebindIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/DynamicWebAppClusterRebindIntegrationTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/DynamicWebAppClusterRebindIntegrationTest.java
index 0005f49..c1624d9 100644
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/DynamicWebAppClusterRebindIntegrationTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/DynamicWebAppClusterRebindIntegrationTest.java
@@ -30,6 +30,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
+import brooklyn.test.TestResourceUnavailableException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.annotations.AfterMethod;
@@ -56,7 +57,6 @@ import com.google.common.io.Files;
 public class DynamicWebAppClusterRebindIntegrationTest {
     private static final Logger LOG = LoggerFactory.getLogger(DynamicWebAppClusterRebindIntegrationTest.class);
     
-    private URL warUrl;
     private LocalhostMachineProvisioningLocation localhostProvisioningLocation;
     private TestApplication origApp;
     private TestApplication newApp;
@@ -69,9 +69,6 @@ public class DynamicWebAppClusterRebindIntegrationTest {
     
     @BeforeMethod(groups = "Integration")
     public void setUp() {
-        String warPath = "hello-world.war";
-        warUrl = getClass().getClassLoader().getResource(warPath);
-        
         executor = Executors.newCachedThreadPool();
 
         mementoDir = Files.createTempDir();
@@ -92,6 +89,11 @@ public class DynamicWebAppClusterRebindIntegrationTest {
         if (mementoDir != null) RebindTestUtils.deleteMementoDir(mementoDir);
     }
 
+    public String getTestWar() {
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war");
+        return "classpath://hello-world.war";
+    }
+
     private TestApplication rebind() throws Exception {
         RebindTestUtils.waitForPersisted(origApp);
         
@@ -113,7 +115,7 @@ public class DynamicWebAppClusterRebindIntegrationTest {
     @Test(groups = "Integration")
     public void testRebindsToRunningCluster() throws Exception {
         DynamicWebAppCluster origCluster = origApp.createAndManageChild(EntitySpec.create(DynamicWebAppCluster.class)
-                .configure("memberSpec", EntitySpec.create(JBoss7Server.class).configure("war", warUrl.toString()))
+                .configure("memberSpec", EntitySpec.create(JBoss7Server.class).configure("war", getTestWar()))
                 .configure("initialSize", 1));
         
         origApp.start(ImmutableList.of(localhostProvisioningLocation));

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dc903822/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss6ServerAwsEc2LiveTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss6ServerAwsEc2LiveTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss6ServerAwsEc2LiveTest.java
index 18939a9..fe53ef4 100644
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss6ServerAwsEc2LiveTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss6ServerAwsEc2LiveTest.java
@@ -23,6 +23,7 @@ import static org.testng.Assert.assertNotNull;
 
 import java.net.URL;
 
+import brooklyn.test.TestResourceUnavailableException;
 import org.testng.annotations.Test;
 
 import brooklyn.entity.AbstractEc2LiveTest;
@@ -38,12 +39,15 @@ import com.google.common.collect.ImmutableList;
  */
 public class JBoss6ServerAwsEc2LiveTest extends AbstractEc2LiveTest {
     
-    private URL warUrl = checkNotNull(getClass().getClassLoader().getResource("hello-world-no-mapping.war"));
-    
+    public String getTestWar() {
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world-no-mapping.war");
+        return "classpath://hello-world-no-mapping.war";
+    }
+
     @Override
     protected void doTest(Location loc) throws Exception {
         final JBoss6Server server = app.createAndManageChild(EntitySpec.create(JBoss6Server.class)
-                .configure("war", warUrl.toString()));
+                .configure("war", getTestWar()));
         
         app.start(ImmutableList.of(loc));
         

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dc903822/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss6ServerNonInheritingIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss6ServerNonInheritingIntegrationTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss6ServerNonInheritingIntegrationTest.java
index 00686c5..c3f5e5e 100644
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss6ServerNonInheritingIntegrationTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss6ServerNonInheritingIntegrationTest.java
@@ -23,6 +23,7 @@ import static org.testng.Assert.assertNotNull;
 
 import java.net.URL;
 
+import brooklyn.test.TestResourceUnavailableException;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
@@ -49,18 +50,20 @@ public class JBoss6ServerNonInheritingIntegrationTest extends BrooklynAppLiveTes
     // Port increment for JBoss 6.
     public static final int PORT_INCREMENT = 400;
 
-    private URL warUrl;
     private LocalhostMachineProvisioningLocation localhostProvisioningLocation;
     
     @BeforeMethod(alwaysRun=true)
     public void setUp() throws Exception {
         super.setUp();
-        String warPath = "hello-world-no-mapping.war";
-        warUrl = getClass().getClassLoader().getResource(warPath);
 
         localhostProvisioningLocation = app.newLocalhostProvisioningLocation();
     }
 
+    public String getTestWarWithNoMapping() {
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world-no-mapping.war");
+        return "classpath://hello-world-no-mapping.war";
+    }
+
     @Test(groups = "Integration")
     public void testJmxmp() throws Exception {
         runTest(UsesJmx.JmxAgentModes.JMXMP);
@@ -80,7 +83,7 @@ public class JBoss6ServerNonInheritingIntegrationTest extends BrooklynAppLiveTes
         final JBoss6Server server = app.createAndManageChild(EntitySpec.create(JBoss6Server.class)
                 .configure(JBoss6Server.PORT_INCREMENT, PORT_INCREMENT)
                 .configure(UsesJmx.JMX_AGENT_MODE, jmxAgentMode)
-                .configure("war", warUrl.toString()));
+                .configure("war", getTestWarWithNoMapping()));
 
         app.start(ImmutableList.of(localhostProvisioningLocation));
         

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dc903822/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerAwsEc2LiveTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerAwsEc2LiveTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerAwsEc2LiveTest.java
index 575a708..60db294 100644
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerAwsEc2LiveTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerAwsEc2LiveTest.java
@@ -23,6 +23,7 @@ import static org.testng.Assert.assertNotNull;
 
 import java.net.URL;
 
+import brooklyn.test.TestResourceUnavailableException;
 import org.testng.annotations.Test;
 
 import brooklyn.entity.AbstractEc2LiveTest;
@@ -37,13 +38,16 @@ import com.google.common.collect.ImmutableList;
  * A simple test of installing+running on AWS-EC2, using various OS distros and versions. 
  */
 public class JBoss7ServerAwsEc2LiveTest extends AbstractEc2LiveTest {
-    
-    private URL warUrl = checkNotNull(getClass().getClassLoader().getResource("hello-world.war"));
-    
+
+    public String getTestWar() {
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war");
+        return "classpath://hello-world.war";
+    }
+
     @Override
     protected void doTest(Location loc) throws Exception {
         final JBoss7Server server = app.createAndManageChild(EntitySpec.create(JBoss7Server.class)
-                .configure("war", warUrl.toString()));
+                .configure("war", getTestWar()));
         
         app.start(ImmutableList.of(loc));
         

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dc903822/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerDockerLiveTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerDockerLiveTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerDockerLiveTest.java
index 1ac7fb3..69eca5f 100644
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerDockerLiveTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerDockerLiveTest.java
@@ -23,6 +23,7 @@ import brooklyn.entity.software.AbstractDockerLiveTest;
 import brooklyn.location.Location;
 import brooklyn.test.Asserts;
 import brooklyn.test.HttpTestUtils;
+import brooklyn.test.TestResourceUnavailableException;
 import com.google.common.collect.ImmutableList;
 import org.testng.annotations.Test;
 
@@ -36,12 +37,15 @@ import static org.testng.Assert.assertNotNull;
  */
 public class JBoss7ServerDockerLiveTest extends AbstractDockerLiveTest {
 
-   private URL warUrl = checkNotNull(getClass().getClassLoader().getResource("hello-world.war"));
+   public String getTestWar() {
+      TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war");
+      return "classpath://hello-world.war";
+   }
 
    @Override
    protected void doTest(Location loc) throws Exception {
       final JBoss7Server server = app.createAndManageChild(EntitySpec.create(JBoss7Server.class)
-              .configure("war", warUrl.toString()));
+              .configure("war", getTestWar()));
 
       app.start(ImmutableList.of(loc));
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dc903822/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerNonInheritingIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerNonInheritingIntegrationTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerNonInheritingIntegrationTest.java
index 04d5c7a..0c056ca 100644
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerNonInheritingIntegrationTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerNonInheritingIntegrationTest.java
@@ -22,8 +22,8 @@ import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertNotNull;
 
 import java.io.File;
-import java.net.URL;
 
+import brooklyn.test.TestResourceUnavailableException;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
@@ -45,16 +45,12 @@ import com.google.common.collect.ImmutableSet;
  */
 public class JBoss7ServerNonInheritingIntegrationTest {
     
-    private URL warUrl;
     private LocalhostMachineProvisioningLocation localhostProvisioningLocation;
     private TestApplication app;
     private File keystoreFile;
     
     @BeforeMethod(alwaysRun=true)
     public void setUp() throws Exception {
-        String warPath = "hello-world.war";
-        warUrl = getClass().getClassLoader().getResource(warPath);
-
         localhostProvisioningLocation = new LocalhostMachineProvisioningLocation();
         app = TestApplication.Factory.newManagedInstanceForTests();
         keystoreFile = AbstractWebAppFixtureIntegrationTest.createTemporaryKeyStore("myname", "mypass");
@@ -66,10 +62,15 @@ public class JBoss7ServerNonInheritingIntegrationTest {
         if (keystoreFile != null) keystoreFile.delete();
     }
 
+    public String getTestWar() {
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war");
+        return "classpath://hello-world.war";
+    }
+
     @Test(groups = "Integration")
     public void testHttp() throws Exception {
         final JBoss7Server server = app.createAndManageChild(EntitySpec.create(JBoss7Server.class)
-                .configure("war", warUrl.toString()));
+                .configure("war", getTestWar()));
         
         app.start(ImmutableList.of(localhostProvisioningLocation));
         
@@ -97,7 +98,7 @@ public class JBoss7ServerNonInheritingIntegrationTest {
     @Test(groups = {"Integration"})
     public void testHttps() throws Exception {
         final JBoss7Server server = app.createAndManageChild(EntitySpec.create(JBoss7Server.class)
-                .configure("war", warUrl.toString())
+                .configure("war", getTestWar())
                 .configure(JBoss7Server.ENABLED_PROTOCOLS, ImmutableSet.of("https"))
                 .configure(JBoss7Server.HTTPS_SSL_CONFIG, new HttpsSslConfig().keyAlias("myname").keystorePassword("mypass").keystoreUrl(keystoreFile.getAbsolutePath())));
         
@@ -134,7 +135,7 @@ public class JBoss7ServerNonInheritingIntegrationTest {
     @Test(groups = {"Integration"})
     public void testHttpAndHttps() throws Exception {
         final JBoss7Server server = app.createAndManageChild(EntitySpec.create(JBoss7Server.class)
-                .configure("war", warUrl.toString())
+                .configure("war", getTestWar())
                 .configure(JBoss7Server.ENABLED_PROTOCOLS, ImmutableSet.of("http", "https"))
                 .configure(JBoss7Server.HTTPS_SSL_CONFIG, new HttpsSslConfig().keyAlias("myname").keystorePassword("mypass").keystoreUrl(keystoreFile.getAbsolutePath())));
         

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dc903822/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerRebindingIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerRebindingIntegrationTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerRebindingIntegrationTest.java
index 61d92d7..0828fe3 100644
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerRebindingIntegrationTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerRebindingIntegrationTest.java
@@ -20,12 +20,12 @@ package brooklyn.entity.webapp.jboss;
 
 import static org.testng.Assert.assertEquals;
 
-import java.net.URL;
 import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
+import brooklyn.test.TestResourceUnavailableException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.annotations.AfterMethod;
@@ -49,7 +49,6 @@ import com.google.common.collect.Iterables;
 public class JBoss7ServerRebindingIntegrationTest extends RebindTestFixtureWithApp {
     private static final Logger LOG = LoggerFactory.getLogger(JBoss7ServerRebindingIntegrationTest.class);
     
-    private URL warUrl;
     private LocalhostMachineProvisioningLocation localhostProvisioningLocation;
     private TestApplication newApp;
     private List<WebAppMonitor> webAppMonitors = new CopyOnWriteArrayList<WebAppMonitor>();
@@ -59,8 +58,6 @@ public class JBoss7ServerRebindingIntegrationTest extends RebindTestFixtureWithA
     @Override
     public void setUp() throws Exception {
         super.setUp();
-        String warPath = "hello-world.war";
-        warUrl = getClass().getClassLoader().getResource(warPath);
         executor = Executors.newCachedThreadPool();
         localhostProvisioningLocation = (LocalhostMachineProvisioningLocation) origManagementContext.getLocationRegistry().resolve("localhost");
     }
@@ -75,6 +72,11 @@ public class JBoss7ServerRebindingIntegrationTest extends RebindTestFixtureWithA
         super.tearDown();
     }
 
+    public String getTestWar() {
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war");
+        return "classpath://hello-world.war";
+    }
+
     private WebAppMonitor newWebAppMonitor(String url) {
         WebAppMonitor monitor = new WebAppMonitor(url)
 //                .delayMillis(0)
@@ -88,7 +90,7 @@ public class JBoss7ServerRebindingIntegrationTest extends RebindTestFixtureWithA
     public void testRebindsToRunningServer() throws Exception {
         // Start an app-server, and wait for it to be fully up
         JBoss7Server origServer = origApp.createAndManageChild(EntitySpec.create(JBoss7Server.class)
-                    .configure("war", warUrl.toString()));
+                    .configure("war", getTestWar()));
         
         origApp.start(ImmutableList.of(localhostProvisioningLocation));
         
@@ -108,7 +110,7 @@ public class JBoss7ServerRebindingIntegrationTest extends RebindTestFixtureWithA
         HttpTestUtils.assertHttpStatusCodeEventuallyEquals(newRootUrl, 200);
 
         // confirm that deploy() effector affects the correct jboss server 
-        newServer.deploy(warUrl.toString(), "myhello.war");
+        newServer.deploy(getTestWar(), "myhello.war");
         HttpTestUtils.assertHttpStatusCodeEventuallyEquals(newRootUrl+"myhello", 200);
         
         // check we see evidence of the enrichers and sensor-feeds having an effect.

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dc903822/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Jboss7ServerGoogleComputeLiveTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Jboss7ServerGoogleComputeLiveTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Jboss7ServerGoogleComputeLiveTest.java
index 3563aa9..e067c59 100644
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Jboss7ServerGoogleComputeLiveTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Jboss7ServerGoogleComputeLiveTest.java
@@ -23,6 +23,7 @@ import static org.testng.Assert.assertNotNull;
 
 import java.net.URL;
 
+import brooklyn.test.TestResourceUnavailableException;
 import org.testng.annotations.Test;
 
 import brooklyn.entity.AbstractGoogleComputeLiveTest;
@@ -37,13 +38,16 @@ import com.google.common.collect.ImmutableList;
  * A simple test of installing+running on AWS-EC2, using various OS distros and versions. 
  */
 public class Jboss7ServerGoogleComputeLiveTest extends AbstractGoogleComputeLiveTest {
-    
-    private URL warUrl = checkNotNull(getClass().getClassLoader().getResource("hello-world.war"));
-    
+
+    public String getTestWar() {
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war");
+        return "classpath://hello-world.war";
+    }
+
     @Override
     protected void doTest(Location loc) throws Exception {
         final JBoss7Server server = app.createAndManageChild(EntitySpec.create(JBoss7Server.class)
-                .configure("war", warUrl.toString()));
+                .configure("war", getTestWar()));
         
         app.start(ImmutableList.of(loc));
         

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dc903822/software/webapp/src/test/java/brooklyn/entity/webapp/tomcat/TomcatServerEc2LiveTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/tomcat/TomcatServerEc2LiveTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/tomcat/TomcatServerEc2LiveTest.java
index db7e373..ec7f0a1 100644
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/tomcat/TomcatServerEc2LiveTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/webapp/tomcat/TomcatServerEc2LiveTest.java
@@ -23,6 +23,7 @@ import static org.testng.Assert.assertNotNull;
 
 import java.net.URL;
 
+import brooklyn.test.TestResourceUnavailableException;
 import org.testng.annotations.Test;
 
 import brooklyn.entity.AbstractEc2LiveTest;
@@ -37,13 +38,16 @@ import com.google.common.collect.ImmutableList;
  * A simple test of installing+running on AWS-EC2, using various OS distros and versions. 
  */
 public class TomcatServerEc2LiveTest extends AbstractEc2LiveTest {
-    
-    private URL warUrl = checkNotNull(getClass().getClassLoader().getResource("hello-world.war"));
-    
+
+    public String getTestWar() {
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war");
+        return "classpath://hello-world.war";
+    }
+
     @Override
     protected void doTest(Location loc) throws Exception {
         final TomcatServer server = app.createAndManageChild(EntitySpec.create(TomcatServer.class)
-                .configure("war", warUrl.toString()));
+                .configure("war", getTestWar()));
         
         app.start(ImmutableList.of(loc));
         

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dc903822/software/webapp/src/test/java/brooklyn/entity/webapp/tomcat/TomcatServerSoftlayerLiveTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/tomcat/TomcatServerSoftlayerLiveTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/tomcat/TomcatServerSoftlayerLiveTest.java
index 9409cf5..7772a39 100644
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/tomcat/TomcatServerSoftlayerLiveTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/webapp/tomcat/TomcatServerSoftlayerLiveTest.java
@@ -23,6 +23,7 @@ import static org.testng.Assert.assertNotNull;
 
 import java.net.URL;
 
+import brooklyn.test.TestResourceUnavailableException;
 import org.testng.annotations.Test;
 
 import brooklyn.entity.AbstractSoftlayerLiveTest;
@@ -37,13 +38,16 @@ import com.google.common.collect.ImmutableList;
  * A simple test of installing+running on Softlayer, using various OS distros and versions. 
  */
 public class TomcatServerSoftlayerLiveTest extends AbstractSoftlayerLiveTest {
-    
-    private URL warUrl = checkNotNull(getClass().getClassLoader().getResource("hello-world.war"));
-    
+
+    public String getTestWar() {
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war");
+        return "classpath://hello-world.war";
+    }
+
     @Override
     protected void doTest(Location loc) throws Exception {
         final TomcatServer server = app.createAndManageChild(EntitySpec.create(TomcatServer.class)
-                .configure("war", warUrl.toString()));
+                .configure("war", getTestWar()));
         
         app.start(ImmutableList.of(loc));
         

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dc903822/software/webapp/src/test/java/brooklyn/entity/webapp/tomcat/TomcatServerWebAppFixtureIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/tomcat/TomcatServerWebAppFixtureIntegrationTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/tomcat/TomcatServerWebAppFixtureIntegrationTest.java
index 39c775d..49328bc 100644
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/tomcat/TomcatServerWebAppFixtureIntegrationTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/webapp/tomcat/TomcatServerWebAppFixtureIntegrationTest.java
@@ -27,6 +27,7 @@ import java.util.concurrent.Callable;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicReference;
 
+import brooklyn.test.TestResourceUnavailableException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.Assert;
@@ -93,6 +94,7 @@ public class TomcatServerWebAppFixtureIntegrationTest extends AbstractWebAppFixt
     // as parent, but with spring travel
     @DataProvider(name = "entitiesWithWarAndURL")
     public Object[][] entitiesWithWar() {
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war");
         List<Object[]> result = Lists.newArrayList();
         
         for (Object[] entity : basicEntities()) {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dc903822/usage/launcher/src/test/java/brooklyn/launcher/WebAppRunnerTest.java
----------------------------------------------------------------------
diff --git a/usage/launcher/src/test/java/brooklyn/launcher/WebAppRunnerTest.java b/usage/launcher/src/test/java/brooklyn/launcher/WebAppRunnerTest.java
index 2fbd131..23018c3 100644
--- a/usage/launcher/src/test/java/brooklyn/launcher/WebAppRunnerTest.java
+++ b/usage/launcher/src/test/java/brooklyn/launcher/WebAppRunnerTest.java
@@ -24,6 +24,7 @@ import static org.testng.Assert.fail;
 import java.util.List;
 import java.util.Map;
 
+import brooklyn.test.TestResourceUnavailableException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.annotations.AfterMethod;
@@ -94,9 +95,11 @@ public class WebAppRunnerTest {
     public static void assertBrooklynEventuallyAt(String url) {
         HttpTestUtils.assertContentEventuallyContainsText(url, "Brooklyn Web Console");
     }
-    
+
     @Test
     public void testStartSecondaryWar() throws Exception {
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war");
+
         if (!Networking.isPortAvailable(8090))
             fail("Another process is using port 8090 which is required for this test.");
         BrooklynWebServer server = createWebServer(
@@ -117,6 +120,8 @@ public class WebAppRunnerTest {
 
     @Test
     public void testStartSecondaryWarAfter() throws Exception {
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war");
+
         if (!Networking.isPortAvailable(8090))
             fail("Another process is using port 8090 which is required for this test.");
         BrooklynWebServer server = createWebServer(MutableMap.of("port", 8090, "war", "brooklyn.war"));
@@ -137,6 +142,8 @@ public class WebAppRunnerTest {
 
     @Test
     public void testStartWithLauncher() throws Exception {
+        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war");
+
         BrooklynLauncher launcher = BrooklynLauncher.newInstance()
                 .brooklynProperties("brooklyn.webconsole.security.provider","brooklyn.rest.security.provider.AnyoneSecurityProvider")
                 .webapp("/hello", "hello-world.war")