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

[1/2] incubator-brooklyn git commit: Adds RebindOptions for RebindTestUtils etc

Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master d6a9aec91 -> 0f2f63279


Adds RebindOptions for RebindTestUtils etc

- Changes RebindTestFixture default to not checkSerializable.
- Deprecates crazy number of overloaded methods


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

Branch: refs/heads/master
Commit: 3dc4405c8c948b265c46cf13633549eaaaf0f6aa
Parents: cb043e2
Author: Aled Sage <al...@gmail.com>
Authored: Tue Nov 4 16:36:33 2014 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Mon Nov 17 15:50:02 2014 +0000

----------------------------------------------------------------------
 .../rebind/RebindEntityDynamicTypeInfoTest.java |   5 -
 .../entity/rebind/RebindEntityTest.java         |  11 +-
 .../entity/rebind/RebindFailuresTest.java       |  24 +-
 .../brooklyn/entity/rebind/RebindFeedTest.java  |   6 +-
 .../brooklyn/entity/rebind/RebindOptions.java   |  92 +++++++
 .../entity/rebind/RebindTestFixture.java        | 136 +++++-----
 .../brooklyn/entity/rebind/RebindTestUtils.java | 249 ++++++++++++++++---
 .../transformer/CompoundTransformerTest.java    |   8 +-
 .../access/PortForwardManagerRebindTest.java    |   2 +-
 ...lusterDatabaseExampleAppIntegrationTest.java |   3 +-
 .../entity/pool/ServerPoolRebindTest.java       |   3 +-
 .../event/feed/jmx/RebindJmxFeedTest.java       |   2 +-
 .../bind/BindDnsServerIntegrationTest.java      |  19 +-
 ...assandraDatacenterRebindIntegrationTest.java |   3 +-
 .../proxy/nginx/NginxRebindIntegrationTest.java |   7 +-
 .../JBoss7ServerRebindingIntegrationTest.java   |   3 +-
 16 files changed, 412 insertions(+), 161 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/3dc4405c/core/src/test/java/brooklyn/entity/rebind/RebindEntityDynamicTypeInfoTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/rebind/RebindEntityDynamicTypeInfoTest.java b/core/src/test/java/brooklyn/entity/rebind/RebindEntityDynamicTypeInfoTest.java
index f12ead8..e9e05e6 100644
--- a/core/src/test/java/brooklyn/entity/rebind/RebindEntityDynamicTypeInfoTest.java
+++ b/core/src/test/java/brooklyn/entity/rebind/RebindEntityDynamicTypeInfoTest.java
@@ -45,11 +45,6 @@ public class RebindEntityDynamicTypeInfoTest extends RebindTestFixtureWithApp {
 
     private static final Logger log = LoggerFactory.getLogger(RebindEntityDynamicTypeInfoTest.class);
     
-    @Override
-    protected TestApplication rebind() throws Exception {
-        return rebind(false);
-    }
-    
     public static class SayHiBody extends EffectorBody<String> {
         public static final ConfigKey<String> NAME_KEY = ConfigKeys.newStringConfigKey("name");
         public static final Effector<String> EFFECTOR = Effectors.effector(String.class, "say_hi").description("says hello")

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/3dc4405c/core/src/test/java/brooklyn/entity/rebind/RebindEntityTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/rebind/RebindEntityTest.java b/core/src/test/java/brooklyn/entity/rebind/RebindEntityTest.java
index 464fe65..d6faccf 100644
--- a/core/src/test/java/brooklyn/entity/rebind/RebindEntityTest.java
+++ b/core/src/test/java/brooklyn/entity/rebind/RebindEntityTest.java
@@ -247,7 +247,7 @@ public class RebindEntityTest extends RebindTestFixtureWithApp {
         reffer.myEntity = origE;
         origApp.setConfig(TestEntity.CONF_OBJECT, reffer);
 
-        newApp = rebind(false);
+        newApp = rebind();
         MyEntity newE = (MyEntity) Iterables.find(newApp.getChildren(), Predicates.instanceOf(MyEntity.class));
         ReffingEntity reffer2 = (ReffingEntity)newApp.getConfig(TestEntity.CONF_OBJECT);
         
@@ -267,7 +267,7 @@ public class RebindEntityTest extends RebindTestFixtureWithApp {
         reffer.resizable = origE;
         origApp.setConfig(TestEntity.CONF_OBJECT, reffer);
 
-        newApp = rebind(false);
+        newApp = rebind();
         MyEntityWithMultipleInterfaces newE = (MyEntityWithMultipleInterfaces) Iterables.find(newApp.getChildren(), Predicates.instanceOf(MyEntityWithMultipleInterfaces.class));
         ReffingEntity newReffer = (ReffingEntity)newApp.getConfig(TestEntity.CONF_OBJECT);
         
@@ -281,7 +281,7 @@ public class RebindEntityTest extends RebindTestFixtureWithApp {
         origE.tags().addTag("foo");
         origE.tags().addTag(origApp);
 
-        newApp = rebind(false);
+        newApp = rebind();
         MyEntity newE = Iterables.getOnlyElement( Entities.descendants(newApp, MyEntity.class) );
 
         assertTrue(newE.tags().containsTag("foo"), "tags are "+newE.tags().getTags());
@@ -390,7 +390,10 @@ public class RebindEntityTest extends RebindTestFixtureWithApp {
         Thread thread = new Thread() {
             public void run() {
                 try {
-                    RebindTestUtils.rebind(newManagementContext, mementoDir, getClass().getClassLoader());
+                    RebindTestUtils.rebind(RebindOptions.create()
+                            .newManagementContext(newManagementContext)
+                            .mementoDir(mementoDir)
+                            .classLoader(RebindEntityTest.class.getClassLoader()));
                 } catch (Exception e) {
                     throw Throwables.propagate(e);
                 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/3dc4405c/core/src/test/java/brooklyn/entity/rebind/RebindFailuresTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/rebind/RebindFailuresTest.java b/core/src/test/java/brooklyn/entity/rebind/RebindFailuresTest.java
index 045d91c8..c522b59 100644
--- a/core/src/test/java/brooklyn/entity/rebind/RebindFailuresTest.java
+++ b/core/src/test/java/brooklyn/entity/rebind/RebindFailuresTest.java
@@ -44,6 +44,8 @@ import brooklyn.entity.rebind.RebindManager.RebindFailureMode;
 import brooklyn.entity.trait.Identifiable;
 import brooklyn.event.AttributeSensor;
 import brooklyn.management.EntityManager;
+import brooklyn.management.ManagementContext;
+import brooklyn.management.internal.LocalManagementContext;
 import brooklyn.policy.Enricher;
 import brooklyn.policy.EnricherSpec;
 import brooklyn.policy.Policy;
@@ -70,7 +72,7 @@ public class RebindFailuresTest extends RebindTestFixtureWithApp {
                 .impl(MyEntityFailingImpl.class)
                 .configure(MyEntityFailingImpl.FAIL_ON_GENERATE_MEMENTO, true));
         
-        newApp = rebind(false);
+        newApp = rebind();
         MyEntity newE = (MyEntity) Iterables.find(newApp.getChildren(), EntityPredicates.idEqualTo(origE.getId()));
         Optional<Entity> newFailingE = Iterables.tryFind(newApp.getChildren(), EntityPredicates.idEqualTo(origFailingE.getId()));
         
@@ -93,11 +95,11 @@ public class RebindFailuresTest extends RebindTestFixtureWithApp {
                 .impl(MyEntityFailingImpl.class)
                 .configure(MyEntityFailingImpl.FAIL_ON_REBIND, true));
         
-        newManagementContext = LocalManagementContextForTests.newInstance();
+        ManagementContext newManagementContext = LocalManagementContextForTests.newInstance();
         EntityManager newEntityManager = newManagementContext.getEntityManager();
         RecordingRebindExceptionHandler exceptionHandler = new RecordingRebindExceptionHandler(danglingRefFailureMode, rebindFailureMode);
         try {
-            newApp = rebind(newManagementContext, exceptionHandler);
+            newApp = rebind(RebindOptions.create().newManagementContext(newManagementContext).exceptionHandler(exceptionHandler));
             fail();
         } catch (Exception e) {
             assertFailureRebindingError(e);
@@ -120,11 +122,11 @@ public class RebindFailuresTest extends RebindTestFixtureWithApp {
                 .impl(MyEntityFailingImpl.class)
                 .configure(MyEntityFailingImpl.FAIL_ON_REBIND, true));
         
-        newManagementContext = LocalManagementContextForTests.newInstance();
+        ManagementContext newManagementContext = LocalManagementContextForTests.newInstance();
         EntityManager newEntityManager = newManagementContext.getEntityManager();
         RecordingRebindExceptionHandler exceptionHandler = new RecordingRebindExceptionHandler(danglingRefFailureMode, rebindFailureMode);
         try {
-            newApp = rebind(newManagementContext, exceptionHandler);
+            newApp = rebind(RebindOptions.create().newManagementContext(newManagementContext).exceptionHandler(exceptionHandler));
             fail();
         } catch (Exception e) {
             assertFailureRebindingError(e);
@@ -147,10 +149,10 @@ public class RebindFailuresTest extends RebindTestFixtureWithApp {
                 .impl(MyEntityFailingImpl.class)
                 .configure(MyEntityFailingImpl.FAIL_ON_REBIND, true));
         
-        newManagementContext = LocalManagementContextForTests.newInstance();
+        ManagementContext newManagementContext = LocalManagementContextForTests.newInstance();
         EntityManager newEntityManager = newManagementContext.getEntityManager();
         RecordingRebindExceptionHandler exceptionHandler = new RecordingRebindExceptionHandler(danglingRefFailureMode, rebindFailureMode);
-        newApp = rebind(newManagementContext, exceptionHandler);
+        newApp = rebind(RebindOptions.create().newManagementContext(newManagementContext).exceptionHandler(exceptionHandler));
 
         // exception handler should have been told about failure
         assertEquals(toIds(exceptionHandler.rebindFailures.keySet()), ImmutableSet.of(origFailingE.getId()));
@@ -169,10 +171,10 @@ public class RebindFailuresTest extends RebindTestFixtureWithApp {
         File entitiesDir = Os.mkdirs(new File(mementoDir, "entities"));
         Files.write("invalid text", new File(entitiesDir, "mycorruptfile"), Charsets.UTF_8);
         
-        newManagementContext = LocalManagementContextForTests.newInstance();
+        LocalManagementContext newManagementContext = LocalManagementContextForTests.newInstance();
         RecordingRebindExceptionHandler exceptionHandler = new RecordingRebindExceptionHandler(danglingRefFailureMode, rebindFailureMode);
         try {
-            newApp = rebind(newManagementContext, exceptionHandler);
+            newApp = rebind(RebindOptions.create().newManagementContext(newManagementContext).exceptionHandler(exceptionHandler));
             fail();
         } catch (Exception e) {
             assertFailureRebindingError(e);
@@ -195,7 +197,7 @@ public class RebindFailuresTest extends RebindTestFixtureWithApp {
         origApp.addPolicy(PolicySpec.create(MyPolicyFailingImpl.class)
                 .configure(MyPolicyFailingImpl.FAIL_ON_REBIND, true));
         
-        newApp = rebind(false);
+        newApp = rebind();
         
         Optional<Policy> newPolicy = Iterables.tryFind(newApp.getPolicies(), Predicates.instanceOf(MyPolicyFailingImpl.class));
         assertFalse(newPolicy.isPresent(), "policy="+newPolicy);
@@ -206,7 +208,7 @@ public class RebindFailuresTest extends RebindTestFixtureWithApp {
         origApp.addEnricher(EnricherSpec.create(MyEnricherFailingImpl.class)
                 .configure(MyEnricherFailingImpl.FAIL_ON_REBIND, true));
         
-        newApp = rebind(false);
+        newApp = rebind();
         
         Optional<Enricher> newEnricher = Iterables.tryFind(newApp.getEnrichers(), Predicates.instanceOf(MyEnricherFailingImpl.class));
         assertFalse(newEnricher.isPresent(), "enricher="+newEnricher);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/3dc4405c/core/src/test/java/brooklyn/entity/rebind/RebindFeedTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/rebind/RebindFeedTest.java b/core/src/test/java/brooklyn/entity/rebind/RebindFeedTest.java
index c0be0fb..5717ed1 100644
--- a/core/src/test/java/brooklyn/entity/rebind/RebindFeedTest.java
+++ b/core/src/test/java/brooklyn/entity/rebind/RebindFeedTest.java
@@ -108,7 +108,7 @@ public class RebindFeedTest extends RebindTestFixtureWithApp {
         log.info("Tasks before rebind: "+
             ((BasicExecutionManager)origManagementContext.getExecutionManager()).getAllTasks());
         
-        newApp = rebind(false);
+        newApp = rebind();
         TestEntity newEntity = (TestEntity) Iterables.getOnlyElement(newApp.getChildren());
         
         Collection<Feed> newFeeds = newEntity.feeds().getFeeds();
@@ -152,7 +152,7 @@ public class RebindFeedTest extends RebindTestFixtureWithApp {
         EntityTestUtils.assertAttributeEqualsEventually(origEntity, SENSOR_INT, (Integer)1);
         assertEquals(origEntity.feeds().getFeeds().size(), 2);
 
-        newApp = rebind(false);
+        newApp = rebind();
         TestEntity newEntity = (TestEntity) Iterables.getOnlyElement(newApp.getChildren());
         
         Collection<Feed> newFeeds = newEntity.feeds().getFeeds();
@@ -176,7 +176,7 @@ public class RebindFeedTest extends RebindTestFixtureWithApp {
         EntityTestUtils.assertAttributeEqualsEventually(origEntity, SENSOR_INT, (Integer)0);
         assertEquals(origEntity.feeds().getFeeds().size(), 1);
 
-        newApp = rebind(false);
+        newApp = rebind();
         TestEntity newEntity = (TestEntity) Iterables.getOnlyElement(newApp.getChildren());
         
         Collection<Feed> newFeeds = newEntity.feeds().getFeeds();

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/3dc4405c/core/src/test/java/brooklyn/entity/rebind/RebindOptions.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/rebind/RebindOptions.java b/core/src/test/java/brooklyn/entity/rebind/RebindOptions.java
new file mode 100644
index 0000000..63bd1cc
--- /dev/null
+++ b/core/src/test/java/brooklyn/entity/rebind/RebindOptions.java
@@ -0,0 +1,92 @@
+/*
+ * 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.entity.rebind;
+
+import java.io.File;
+
+import brooklyn.entity.rebind.persister.PersistenceObjectStore;
+import brooklyn.management.ManagementContext;
+
+/**
+ * See {@link RebindTestFixture#rebind(RebindOptions)} and {@link RebindTestUtils#rebind(RebindOptions}}.
+ */
+public class RebindOptions {
+    boolean checkSerializable;
+    boolean terminateOrigManagementContext;
+    RebindExceptionHandler exceptionHandler;
+    ManagementContext origManagementContext;
+    ManagementContext newManagementContext;
+    File mementoDir;
+    File mementoDirBackup;
+    ClassLoader classLoader;
+    PersistenceObjectStore objectStore;
+    
+    public static RebindOptions create() {
+        return new RebindOptions();
+    }
+    public static RebindOptions create(RebindOptions options) {
+        RebindOptions result = create();
+        result.checkSerializable(options.checkSerializable);
+        result.terminateOrigManagementContext(options.terminateOrigManagementContext);
+        result.exceptionHandler(options.exceptionHandler);
+        result.origManagementContext(options.origManagementContext);
+        result.newManagementContext(options.newManagementContext);
+        result.mementoDir(options.mementoDir);
+        result.mementoDirBackup(options.mementoDirBackup);
+        result.classLoader(options.classLoader);
+        result.objectStore(options.objectStore);
+        return result;
+    }
+    public RebindOptions checkSerializable(boolean val) {
+        this.checkSerializable = val;
+        return this;
+    }
+    public RebindOptions terminateOrigManagementContext(boolean val) {
+        this.terminateOrigManagementContext = val;
+        return this;
+    }
+    public RebindOptions exceptionHandler(RebindExceptionHandler val) {
+        this.exceptionHandler = val;
+        return this;
+    }
+    public RebindOptions origManagementContext(ManagementContext val) {
+        this.origManagementContext = val;
+        return this;
+    }
+    public RebindOptions newManagementContext(ManagementContext val) {
+        this.newManagementContext = val;
+        return this;
+    }
+    public RebindOptions mementoDir(File val) {
+        this.mementoDir = val;
+        return this;
+    }
+    public RebindOptions mementoDirBackup(File val) {
+        this.mementoDirBackup = val;
+        return this;
+    }
+    public RebindOptions classLoader(ClassLoader val) {
+        this.classLoader = val;
+        return this;
+    }
+    public RebindOptions objectStore(PersistenceObjectStore val) {
+        this.objectStore = val;
+        return this;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/3dc4405c/core/src/test/java/brooklyn/entity/rebind/RebindTestFixture.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/rebind/RebindTestFixture.java b/core/src/test/java/brooklyn/entity/rebind/RebindTestFixture.java
index 2b221d1..24bf357 100644
--- a/core/src/test/java/brooklyn/entity/rebind/RebindTestFixture.java
+++ b/core/src/test/java/brooklyn/entity/rebind/RebindTestFixture.java
@@ -21,8 +21,6 @@ package brooklyn.entity.rebind;
 import static org.testng.Assert.assertEquals;
 
 import java.io.File;
-import java.util.List;
-import java.util.Map;
 import java.util.Set;
 
 import org.slf4j.Logger;
@@ -33,7 +31,6 @@ import org.testng.annotations.BeforeMethod;
 import brooklyn.catalog.BrooklynCatalog;
 import brooklyn.catalog.CatalogItem;
 import brooklyn.catalog.internal.CatalogUtils;
-import brooklyn.config.BrooklynProperties;
 import brooklyn.entity.basic.Entities;
 import brooklyn.entity.basic.EntityFunctions;
 import brooklyn.entity.basic.StartableApplication;
@@ -45,17 +42,12 @@ import brooklyn.management.ha.HighAvailabilityMode;
 import brooklyn.management.internal.LocalManagementContext;
 import brooklyn.management.internal.ManagementContextInternal;
 import brooklyn.mementos.BrooklynMementoManifest;
-import brooklyn.mementos.BrooklynMementoRawData;
-import brooklyn.test.entity.LocalManagementContextForTests;
-import brooklyn.util.io.FileUtil;
 import brooklyn.util.os.Os;
 import brooklyn.util.text.Identifiers;
 import brooklyn.util.time.Duration;
 
 import com.google.api.client.util.Sets;
-import com.google.common.annotations.Beta;
 import com.google.common.collect.FluentIterable;
-import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Iterables;
 
 public abstract class RebindTestFixture<T extends StartableApplication> {
@@ -73,6 +65,7 @@ public abstract class RebindTestFixture<T extends StartableApplication> {
     protected T newApp;
     protected ManagementContext newManagementContext;
 
+
     @BeforeMethod(alwaysRun=true)
     public void setUp() throws Exception {
         mementoDir = Os.newTempDir(getClass());
@@ -132,94 +125,83 @@ public abstract class RebindTestFixture<T extends StartableApplication> {
         origManagementContext = null;
     }
 
+    /** rebinds, and sets newApp */
+    protected T rebind() throws Exception {
+        return rebind(RebindOptions.create());
+    }
+
     /**
-     * Dumps out the persisted mementos that are at the given directory.
-     * 
-     * Binds to the persisted state (as a "hot standby") to load the raw data (as strings), and to write out the
-     * entity, location, policy, enricher, feed and catalog-item data.
+     * Checking serializable is overly strict.
+     * State only needs to be xstream-serializable, which does not require `implements Serializable`. 
+     * Also, the xstream serializer has some special hooks that replaces an entity reference with 
+     * a marker for that entity, etc.
      * 
-     * @param dir The directory containing the persisted state (e.g. {@link #mementoDir} or {@link #mementoDirBackup})
+     * @deprecated since 0.7.0; use {@link #rebind()} or {@link #rebind(RebindOptions)})
      */
-    protected void dumpMementoDir(File dir) {
-        LocalManagementContextForTests mgmt = new LocalManagementContextForTests(BrooklynProperties.Factory.newEmpty());
-        FileBasedObjectStore store = null;
-        BrooklynMementoPersisterToObjectStore persister = null;
-        try {
-            store = new FileBasedObjectStore(dir);
-            store.injectManagementContext(mgmt);
-            store.prepareForSharedUse(PersistMode.AUTO, HighAvailabilityMode.HOT_STANDBY);
-            persister = new BrooklynMementoPersisterToObjectStore(store, BrooklynProperties.Factory.newEmpty(), classLoader);
-            BrooklynMementoRawData data = persister.loadMementoRawData(RebindExceptionHandlerImpl.builder().build());
-            List<BrooklynObjectType> types = ImmutableList.of(BrooklynObjectType.ENTITY, BrooklynObjectType.LOCATION, 
-                    BrooklynObjectType.POLICY, BrooklynObjectType.ENRICHER, BrooklynObjectType.FEED, 
-                    BrooklynObjectType.CATALOG_ITEM);
-            for (BrooklynObjectType type : types) {
-                LOG.info(type+" ("+data.getObjectsOfType(type).keySet()+"):");
-                for (Map.Entry<String, String> entry : data.getObjectsOfType(type).entrySet()) {
-                    LOG.info("\t"+type+" "+entry.getKey()+": "+entry.getValue());
-                }
-            }
-        } finally {
-            if (persister != null) persister.stop(false);
-            if (store != null) store.close();
-            mgmt.terminate();
-        }
+    @Deprecated
+    protected T rebind(boolean checkSerializable) throws Exception {
+        return rebind(RebindOptions.create().checkSerializable(checkSerializable));
     }
     
-    /** rebinds, and sets newApp */
-    protected T rebind() throws Exception {
-        return rebind(true);
+    /**
+     * Checking serializable is overly strict.
+     * State only needs to be xstream-serializable, which does not require `implements Serializable`. 
+     * Also, the xstream serializer has some special hooks that replaces an entity reference with 
+     * a marker for that entity, etc.
+     * 
+     * @deprecated since 0.7.0; use {@link #rebind(RebindOptions)})
+     */
+    @Deprecated
+    protected T rebind(boolean checkSerializable, boolean terminateOrigManagementContext) throws Exception {
+        return rebind(RebindOptions.create()
+                .checkSerializable(checkSerializable)
+                .terminateOrigManagementContext(terminateOrigManagementContext));
     }
 
     /**
-     * TODO We should (probably?!) change everywhere from asserting that they are serializable. 
-     * They only need to be xstream-serializable, which does not require `implements Serializable`. 
-     * Also, the xstream serializer has some special hooks that replaces an entity reference with 
-     * a marker for that entity, etc. Suggest we change the default {@link #rebind()} to use 
-     * {@code checkSerializable==false}, and deprecate this + the other overloaded methods?
+     * @deprecated since 0.7.0; use {@link #rebind(RebindOptions)})
      */
-    protected T rebind(boolean checkSerializable) throws Exception {
-        // TODO What are sensible defaults?!
-        return rebind(checkSerializable, false);
+    @Deprecated
+    protected T rebind(RebindExceptionHandler exceptionHandler) throws Exception {
+        return rebind(RebindOptions.create().exceptionHandler(exceptionHandler));
     }
 
-    protected T rebind(boolean checkSerializable, boolean terminateOrigManagementContext) throws Exception {
-        return rebind(checkSerializable, terminateOrigManagementContext, (File)null);
+    /**
+     * @deprecated since 0.7.0; use {@link #rebind(RebindOptions)})
+     */
+    @Deprecated
+    protected T rebind(ManagementContext newManagementContext, RebindExceptionHandler exceptionHandler) throws Exception {
+        return rebind(RebindOptions.create()
+                .newManagementContext(newManagementContext)
+                .exceptionHandler(exceptionHandler));
     }
     
-    @Beta // temporary method while debugging; Aled will refactor all of this soon!
     @SuppressWarnings("unchecked")
-    protected T rebind(boolean checkSerializable, boolean terminateOrigManagementContext, File backupDir) throws Exception {
-        if (newApp!=null || newManagementContext!=null) throw new IllegalStateException("already rebound");
+    protected T rebind(RebindOptions options) throws Exception {
+        if (newApp != null || newManagementContext != null) {
+            throw new IllegalStateException("already rebound");
+        }
+        
+        options = RebindOptions.create(options);
+        if (options.classLoader == null) options.classLoader(classLoader);
+        if (options.mementoDir == null) options.mementoDir(mementoDir);
+        if (options.origManagementContext == null) options.origManagementContext(origManagementContext);
+        if (options.newManagementContext == null) options.newManagementContext(createNewManagementContext());
         
         RebindTestUtils.waitForPersisted(origApp);
-        if (checkSerializable) {
-            RebindTestUtils.checkCurrentMementoSerializable(origApp);
-        }
-        if (terminateOrigManagementContext) {
-            origManagementContext.terminate();
-        }
-
-        if (backupDir != null) {
-            FileUtil.copyDir(mementoDir, backupDir);
-            FileUtil.setFilePermissionsTo700(backupDir);
-        }
-
-        newManagementContext = createNewManagementContext();
-        newApp = (T) RebindTestUtils.rebind((LocalManagementContext)newManagementContext, classLoader);
+        
+        newManagementContext = options.newManagementContext;
+        newApp = (T) RebindTestUtils.rebind(options);
         return newApp;
     }
 
-    @SuppressWarnings("unchecked")
-    protected T rebind(RebindExceptionHandler exceptionHandler) throws Exception {
-        RebindTestUtils.waitForPersisted(origApp);
-        return (T) RebindTestUtils.rebind(mementoDir, classLoader, exceptionHandler);
-    }
-
-    @SuppressWarnings("unchecked")
-    protected T rebind(ManagementContext newManagementContext, RebindExceptionHandler exceptionHandler) throws Exception {
-        RebindTestUtils.waitForPersisted(origApp);
-        return (T) RebindTestUtils.rebind(newManagementContext, mementoDir, classLoader, exceptionHandler);
+    /**
+     * Dumps out the persisted mementos that are at the given directory.
+     * 
+     * @param dir The directory containing the persisted state (e.g. {@link #mementoDir} or {@link #mementoDirBackup})
+     */
+    protected void dumpMementoDir(File dir) {
+        RebindTestUtils.dumpMementoDir(dir);
     }
     
     protected BrooklynMementoManifest loadMementoManifest() throws Exception {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/3dc4405c/core/src/test/java/brooklyn/entity/rebind/RebindTestUtils.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/rebind/RebindTestUtils.java b/core/src/test/java/brooklyn/entity/rebind/RebindTestUtils.java
index d3bdeff..daafe58 100644
--- a/core/src/test/java/brooklyn/entity/rebind/RebindTestUtils.java
+++ b/core/src/test/java/brooklyn/entity/rebind/RebindTestUtils.java
@@ -49,11 +49,14 @@ import brooklyn.management.ha.ManagementPlaneSyncRecordPersisterToObjectStore;
 import brooklyn.management.internal.LocalManagementContext;
 import brooklyn.management.internal.ManagementContextInternal;
 import brooklyn.mementos.BrooklynMemento;
+import brooklyn.mementos.BrooklynMementoRawData;
 import brooklyn.test.entity.LocalManagementContextForTests;
+import brooklyn.util.io.FileUtil;
 import brooklyn.util.javalang.Serializers;
 import brooklyn.util.javalang.Serializers.ObjectReplacer;
 import brooklyn.util.time.Duration;
 
+import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Maps;
 
@@ -221,71 +224,197 @@ public class RebindTestUtils {
 
     }
 
+    /**
+     * Convenience for common call; delegates to {@link #rebind(RebindOptions)}
+     */
     public static Application rebind(File mementoDir, ClassLoader classLoader) throws Exception {
-        return rebind(mementoDir, classLoader, null);
+        return rebind(RebindOptions.create()
+                .mementoDir(mementoDir)
+                .classLoader(classLoader));
     }
 
-    public static Application rebind(LocalManagementContext newManagementContext, ClassLoader classLoader) throws Exception {
-        return rebind(newManagementContext, classLoader, null);
+    /**
+     * @deprecated since 0.7.0; use {@link #rebind(RebindOptions)}
+     */
+    @Deprecated
+    public static Application rebind(File mementoDir, ClassLoader classLoader, RebindExceptionHandler exceptionHandler) throws Exception {
+        return rebind(RebindOptions.create()
+                .mementoDir(mementoDir)
+                .classLoader(classLoader)
+                .exceptionHandler(exceptionHandler));
     }
 
-    public static Application rebind(LocalManagementContext newManagementContext, ClassLoader classLoader, RebindExceptionHandler exceptionHandler) throws Exception {
-        Collection<Application> newApps = rebindAll(newManagementContext, classLoader, exceptionHandler);
-        if (newApps.isEmpty()) throw new IllegalStateException("Application could not be rebinded; serialization probably failed");
-        return Iterables.getFirst(newApps, null);
+    /**
+     * @deprecated since 0.7.0; use {@link #rebind(RebindOptions)}
+     */
+    @Deprecated
+    public static Application rebind(ManagementContext newManagementContext, ClassLoader classLoader) throws Exception {
+        return rebind(RebindOptions.create()
+                .newManagementContext(newManagementContext)
+                .classLoader(classLoader));
     }
 
-    public static Application rebind(File mementoDir, ClassLoader classLoader, RebindExceptionHandler exceptionHandler) throws Exception {
-        Collection<Application> newApps = rebindAll(mementoDir, classLoader, exceptionHandler);
-        if (newApps.isEmpty()) throw new IllegalStateException("Application could not be rebinded; serialization probably failed");
-        return Iterables.getFirst(newApps, null);
+    /**
+     * @deprecated since 0.7.0; use {@link #rebind(RebindOptions)}
+     */
+    @Deprecated
+    public static Application rebind(ManagementContext newManagementContext, ClassLoader classLoader, RebindExceptionHandler exceptionHandler) throws Exception {
+        return rebind(RebindOptions.create()
+                .newManagementContext(newManagementContext)
+                .classLoader(classLoader)
+                .exceptionHandler(exceptionHandler));
     }
 
-    public static Collection<Application> rebindAll(File mementoDir, ClassLoader classLoader) throws Exception {
-        return rebindAll(mementoDir, classLoader, null);
+    /**
+     * @deprecated since 0.7.0; use {@link #rebind(RebindOptions)}
+     */
+    @Deprecated
+    public static Application rebind(ManagementContext newManagementContext, File mementoDir, ClassLoader classLoader) throws Exception {
+        return rebind(RebindOptions.create()
+                .newManagementContext(newManagementContext)
+                .mementoDir(mementoDir)
+                .classLoader(classLoader));
     }
 
-    public static Collection<Application> rebindAll(File mementoDir, ClassLoader classLoader, RebindExceptionHandler exceptionHandler) throws Exception {
-        LOG.info("Rebinding app, using directory "+mementoDir);
-        return rebindAll(newPersistingManagementContextUnstarted(mementoDir, classLoader), classLoader, exceptionHandler);
+    /**
+     * @deprecated since 0.7.0; use {@link #rebind(RebindOptions)}
+     */
+    @Deprecated
+    public static Application rebind(ManagementContext newManagementContext, File mementoDir, ClassLoader classLoader, RebindExceptionHandler exceptionHandler) throws Exception {
+        return rebind(RebindOptions.create()
+                .newManagementContext(newManagementContext)
+                .mementoDir(mementoDir)
+                .classLoader(classLoader)
+                .exceptionHandler(exceptionHandler));
     }
     
-    public static Collection<Application> rebindAll(LocalManagementContext newManagementContext, ClassLoader classLoader, RebindExceptionHandler exceptionHandler) throws Exception {
-        LOG.info("Rebinding app");
-
-        List<Application> newApps = newManagementContext.getRebindManager().rebind(classLoader, exceptionHandler, ManagementNodeState.MASTER);
-        
+    /**
+     * @deprecated since 0.7.0; use {@link #rebind(RebindOptions)}
+     */
+    @Deprecated
+    public static Application rebind(ManagementContext newManagementContext, File mementoDir,
+            ClassLoader classLoader, RebindExceptionHandler exceptionHandler, PersistenceObjectStore objectStore) throws Exception {
+        return rebind(RebindOptions.create()
+                .newManagementContext(newManagementContext)
+                .mementoDir(mementoDir)
+                .classLoader(classLoader)
+                .exceptionHandler(exceptionHandler)
+                .objectStore(objectStore));
+    }
+    
+    public static Application rebind(RebindOptions options) throws Exception {
+        Collection<Application> newApps = rebindAll(options);
         if (newApps.isEmpty()) throw new IllegalStateException("Application could not be rebinded; serialization probably failed");
-        newManagementContext.getRebindManager().startPersistence();
-        return newApps;
+        return Iterables.getFirst(newApps, null);
     }
 
-    public static Application rebind(ManagementContext newManagementContext, File mementoDir, ClassLoader classLoader) throws Exception {
-        return rebind(newManagementContext, mementoDir, classLoader, null);
+
+    /**
+     * @deprecated since 0.7.0; use {@link #rebindAll(RebindOptions)}
+     */
+    @Deprecated
+    public static Collection<Application> rebindAll(File mementoDir, ClassLoader classLoader) throws Exception {
+        return rebindAll(RebindOptions.create()
+                .mementoDir(mementoDir)
+                .classLoader(classLoader));
     }
 
-    public static Application rebind(ManagementContext newManagementContext, File mementoDir, ClassLoader classLoader, RebindExceptionHandler exceptionHandler) throws Exception {
-        PersistenceObjectStore objectStore = new FileBasedObjectStore(mementoDir);
-        objectStore.injectManagementContext(newManagementContext);
-        objectStore.prepareForSharedUse(PersistMode.AUTO, HighAvailabilityMode.DISABLED);
-        return rebind(newManagementContext, mementoDir, classLoader, exceptionHandler, objectStore);
+    /**
+     * @deprecated since 0.7.0; use {@link #rebind(RebindOptions)}
+     */
+    @Deprecated
+    public static Collection<Application> rebindAll(File mementoDir, ClassLoader classLoader, RebindExceptionHandler exceptionHandler) throws Exception {
+        return rebindAll(RebindOptions.create()
+                .mementoDir(mementoDir)
+                .classLoader(classLoader)
+                .exceptionHandler(exceptionHandler));
     }
-    public static Application rebind(ManagementContext newManagementContext, File mementoDir,
-                                     ClassLoader classLoader, RebindExceptionHandler exceptionHandler, PersistenceObjectStore objectStore) throws Exception {
-        return Iterables.getFirst(rebindAll(newManagementContext, mementoDir, classLoader, exceptionHandler, objectStore), null);
+    
+    /**
+     * @deprecated since 0.7.0; use {@link #rebind(RebindOptions)}
+     */
+    @Deprecated
+    public static Collection<Application> rebindAll(LocalManagementContext newManagementContext, ClassLoader classLoader, RebindExceptionHandler exceptionHandler) throws Exception {
+        return rebindAll(RebindOptions.create()
+                .newManagementContext(newManagementContext)
+                .classLoader(classLoader)
+                .exceptionHandler(exceptionHandler));
     }
+
+    /**
+     * @deprecated since 0.7.0; use {@link #rebind(RebindOptions)}
+     */
+    @Deprecated
     public static Collection<Application> rebindAll(ManagementContext newManagementContext, File mementoDir, ClassLoader classLoader) throws Exception {
-        return rebindAll(newManagementContext, mementoDir, classLoader, null, new FileBasedObjectStore(mementoDir));
+        return rebindAll(RebindOptions.create()
+                .newManagementContext(newManagementContext)
+                .mementoDir(mementoDir)
+                .classLoader(classLoader));
     }
 
+    /**
+     * @deprecated since 0.7.0; use {@link #rebind(RebindOptions)}
+     */
+    @Deprecated
     public static Collection<Application> rebindAll(ManagementContext newManagementContext, File mementoDir, ClassLoader classLoader, RebindExceptionHandler exceptionHandler, PersistenceObjectStore objectStore) throws Exception {
-        LOG.info("Rebinding app, using directory "+mementoDir);
+        return rebindAll(RebindOptions.create()
+                .newManagementContext(newManagementContext)
+                .mementoDir(mementoDir)
+                .classLoader(classLoader)
+                .exceptionHandler(exceptionHandler)
+                .objectStore(objectStore));
+    }
+
+    public static Collection<Application> rebindAll(RebindOptions options) throws Exception {
+        File mementoDir = options.mementoDir;
+        File mementoDirBackup = options.mementoDirBackup;
+        ClassLoader classLoader = checkNotNull(options.classLoader, "classLoader");
+        ManagementContextInternal origManagementContext = (ManagementContextInternal) options.origManagementContext;
+        ManagementContextInternal newManagementContext = (ManagementContextInternal) options.newManagementContext;
+        PersistenceObjectStore objectStore = options.objectStore;
+        RebindExceptionHandler exceptionHandler = options.exceptionHandler;
+        boolean hasPersister = newManagementContext != null && newManagementContext.getRebindManager().getPersister() != null;
+        boolean checkSerializable = options.checkSerializable;
+        boolean terminateOrigManagementContext = options.terminateOrigManagementContext;
+        
+        LOG.info("Rebinding app, using mementoDir " + mementoDir + "; object store " + objectStore);
+
+        if (newManagementContext == null) {
+            // TODO Could use empty properties, to save reading brooklyn.properties file.
+            // Would that affect any tests?
+            newManagementContext = new LocalManagementContextForTests(BrooklynProperties.Factory.newDefault());
+        }
+        if (!hasPersister) {
+            if (objectStore == null) {
+                objectStore = new FileBasedObjectStore(checkNotNull(mementoDir, "mementoDir and objectStore must not both be null"));
+            }
+            objectStore.injectManagementContext(newManagementContext);
+            objectStore.prepareForSharedUse(PersistMode.AUTO, HighAvailabilityMode.DISABLED);
+            
+            BrooklynMementoPersisterToObjectStore newPersister = new BrooklynMementoPersisterToObjectStore(
+                    objectStore,
+                    newManagementContext.getBrooklynProperties(),
+                    classLoader);
+            newManagementContext.getRebindManager().setPersister(newPersister, PersistenceExceptionHandlerImpl.builder().build());
+        } else {
+            if (objectStore != null) throw new IllegalStateException("Must not supply ManagementContext with persister and an object store");
+        }
+        
+        if (checkSerializable) {
+            checkNotNull(origManagementContext, "must supply origManagementContext with checkSerializable");
+            RebindTestUtils.checkCurrentMementoSerializable(origManagementContext);
+        }
 
-        BrooklynMementoPersisterToObjectStore newPersister = new BrooklynMementoPersisterToObjectStore(
-                objectStore,
-                ((ManagementContextInternal)newManagementContext).getBrooklynProperties(),
-                classLoader);
-        newManagementContext.getRebindManager().setPersister(newPersister, PersistenceExceptionHandlerImpl.builder().build());
+        if (terminateOrigManagementContext) {
+            checkNotNull(origManagementContext, "must supply origManagementContext with terminateOrigManagementContext");
+            origManagementContext.terminate();
+        }
+        
+        if (mementoDirBackup != null) {
+            FileUtil.copyDir(mementoDir, mementoDirBackup);
+            FileUtil.setFilePermissionsTo700(mementoDirBackup);
+        }
+        
         List<Application> newApps = newManagementContext.getRebindManager().rebind(classLoader, exceptionHandler, ManagementNodeState.MASTER);
         newManagementContext.getRebindManager().startPersistence();
         return newApps;
@@ -300,7 +429,45 @@ public class RebindTestUtils {
     }
 
     public static void checkCurrentMementoSerializable(Application app) throws Exception {
-        BrooklynMemento memento = MementosGenerators.newBrooklynMemento(app.getManagementContext());
+        checkCurrentMementoSerializable(app.getManagementContext());
+    }
+    
+    public static void checkCurrentMementoSerializable(ManagementContext mgmt) throws Exception {
+        BrooklynMemento memento = MementosGenerators.newBrooklynMemento(mgmt);
         serializeAndDeserialize(memento);
     }
+    
+    /**
+     * Dumps out the persisted mementos that are at the given directory.
+     * 
+     * Binds to the persisted state (as a "hot standby") to load the raw data (as strings), and to write out the
+     * entity, location, policy, enricher, feed and catalog-item data.
+     * 
+     * @param dir The directory containing the persisted state
+     */
+    public static void dumpMementoDir(File dir) {
+        LocalManagementContextForTests mgmt = new LocalManagementContextForTests(BrooklynProperties.Factory.newEmpty());
+        FileBasedObjectStore store = null;
+        BrooklynMementoPersisterToObjectStore persister = null;
+        try {
+            store = new FileBasedObjectStore(dir);
+            store.injectManagementContext(mgmt);
+            store.prepareForSharedUse(PersistMode.AUTO, HighAvailabilityMode.HOT_STANDBY);
+            persister = new BrooklynMementoPersisterToObjectStore(store, BrooklynProperties.Factory.newEmpty(), RebindTestUtils.class.getClassLoader());
+            BrooklynMementoRawData data = persister.loadMementoRawData(RebindExceptionHandlerImpl.builder().build());
+            List<BrooklynObjectType> types = ImmutableList.of(BrooklynObjectType.ENTITY, BrooklynObjectType.LOCATION, 
+                    BrooklynObjectType.POLICY, BrooklynObjectType.ENRICHER, BrooklynObjectType.FEED, 
+                    BrooklynObjectType.CATALOG_ITEM);
+            for (BrooklynObjectType type : types) {
+                LOG.info(type+" ("+data.getObjectsOfType(type).keySet()+"):");
+                for (Map.Entry<String, String> entry : data.getObjectsOfType(type).entrySet()) {
+                    LOG.info("\t"+type+" "+entry.getKey()+": "+entry.getValue());
+                }
+            }
+        } finally {
+            if (persister != null) persister.stop(false);
+            if (store != null) store.close();
+            mgmt.terminate();
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/3dc4405c/core/src/test/java/brooklyn/entity/rebind/transformer/CompoundTransformerTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/rebind/transformer/CompoundTransformerTest.java b/core/src/test/java/brooklyn/entity/rebind/transformer/CompoundTransformerTest.java
index 9474cd8..c8cc39d 100644
--- a/core/src/test/java/brooklyn/entity/rebind/transformer/CompoundTransformerTest.java
+++ b/core/src/test/java/brooklyn/entity/rebind/transformer/CompoundTransformerTest.java
@@ -35,6 +35,7 @@ import brooklyn.entity.Entity;
 import brooklyn.entity.rebind.PersistenceExceptionHandler;
 import brooklyn.entity.rebind.PersistenceExceptionHandlerImpl;
 import brooklyn.entity.rebind.RebindExceptionHandler;
+import brooklyn.entity.rebind.RebindOptions;
 import brooklyn.entity.rebind.RebindManager.RebindFailureMode;
 import brooklyn.entity.rebind.RebindTestFixtureWithApp;
 import brooklyn.entity.rebind.RebindTestUtils;
@@ -68,7 +69,7 @@ public class CompoundTransformerTest extends RebindTestFixtureWithApp {
         super.tearDown();
         if (newMementoDir != null) FileBasedObjectStore.deleteCompletely(mementoDir);
     }
-    
+
     @Test
     public void testNoopTransformation() throws Exception {
         CompoundTransformer transformer = CompoundTransformer.builder()
@@ -155,7 +156,10 @@ public class CompoundTransformerTest extends RebindTestFixtureWithApp {
                 .forLive(useLiveManagementContext())
                 .buildUnstarted();
 
-        return (TestApplication) RebindTestUtils.rebind((LocalManagementContext)newManagementContext, classLoader);
+        return (TestApplication) RebindTestUtils.rebind(RebindOptions.create()
+                .newManagementContext(newManagementContext)
+                .classLoader(classLoader)
+                .mementoDir(newMementoDir));
     }
     
     public static class OrigType {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/3dc4405c/core/src/test/java/brooklyn/location/access/PortForwardManagerRebindTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/location/access/PortForwardManagerRebindTest.java b/core/src/test/java/brooklyn/location/access/PortForwardManagerRebindTest.java
index 8ae81ce..913e92d 100644
--- a/core/src/test/java/brooklyn/location/access/PortForwardManagerRebindTest.java
+++ b/core/src/test/java/brooklyn/location/access/PortForwardManagerRebindTest.java
@@ -80,7 +80,7 @@ public class PortForwardManagerRebindTest extends RebindTestFixtureWithApp {
         origPortForwardManager.acquirePublicPortExplicit(publicIpId, 40080);
         origPortForwardManager.associate(publicIpId, 40080, origSimulatedMachine, 80);
      
-        newApp = rebind(false);
+        newApp = rebind();
         
         TestEntity newEntity = (TestEntity) Iterables.find(newApp.getChildren(), Predicates.instanceOf(TestEntity.class));
         Location newSimulatedMachine = newApp.getManagementContext().getLocationManager().getLocation(origSimulatedMachine.getId());

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/3dc4405c/examples/simple-web-cluster/src/test/java/brooklyn/demo/RebindWebClusterDatabaseExampleAppIntegrationTest.java
----------------------------------------------------------------------
diff --git a/examples/simple-web-cluster/src/test/java/brooklyn/demo/RebindWebClusterDatabaseExampleAppIntegrationTest.java b/examples/simple-web-cluster/src/test/java/brooklyn/demo/RebindWebClusterDatabaseExampleAppIntegrationTest.java
index f113ca0..19edba9 100644
--- a/examples/simple-web-cluster/src/test/java/brooklyn/demo/RebindWebClusterDatabaseExampleAppIntegrationTest.java
+++ b/examples/simple-web-cluster/src/test/java/brooklyn/demo/RebindWebClusterDatabaseExampleAppIntegrationTest.java
@@ -45,6 +45,7 @@ import brooklyn.entity.group.DynamicCluster;
 import brooklyn.entity.java.JavaEntityMethods;
 import brooklyn.entity.proxy.nginx.NginxController;
 import brooklyn.entity.proxying.EntitySpec;
+import brooklyn.entity.rebind.RebindOptions;
 import brooklyn.entity.rebind.RebindTestFixture;
 import brooklyn.entity.webapp.ControlledDynamicWebAppCluster;
 import brooklyn.entity.webapp.DynamicWebAppCluster;
@@ -121,7 +122,7 @@ public class RebindWebClusterDatabaseExampleAppIntegrationTest extends RebindTes
         String clusterUrl = checkNotNull(origApp.getAttribute(WebClusterDatabaseExampleApp.ROOT_URL), "cluster url");
         WebAppMonitor monitor = newWebAppMonitor(clusterUrl, 200);
         
-        newApp = rebind(false, true);
+        newApp = rebind(RebindOptions.create().terminateOrigManagementContext(true));
         assertAppFunctional(newApp);
 
         // expect no failures during rebind

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/3dc4405c/software/base/src/test/java/brooklyn/entity/pool/ServerPoolRebindTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/brooklyn/entity/pool/ServerPoolRebindTest.java b/software/base/src/test/java/brooklyn/entity/pool/ServerPoolRebindTest.java
index 842b3fa..87feeff 100644
--- a/software/base/src/test/java/brooklyn/entity/pool/ServerPoolRebindTest.java
+++ b/software/base/src/test/java/brooklyn/entity/pool/ServerPoolRebindTest.java
@@ -32,6 +32,7 @@ import org.testng.annotations.Test;
 import brooklyn.entity.Application;
 import brooklyn.entity.Entity;
 import brooklyn.entity.basic.Attributes;
+import brooklyn.entity.rebind.RebindOptions;
 import brooklyn.entity.rebind.RebindTestUtils;
 import brooklyn.management.ManagementContext;
 import brooklyn.management.internal.LocalManagementContext;
@@ -66,7 +67,7 @@ public class ServerPoolRebindTest extends AbstractServerPoolTest {
         LOG.info("Rebind start");
         RebindTestUtils.waitForPersisted(app);
         ((LocalManagementContext) app.getManagementContext()).terminate();
-        Collection<Application> r = RebindTestUtils.rebindAll(mementoDir, getClass().getClassLoader());
+        Collection<Application> r = RebindTestUtils.rebindAll(RebindOptions.create().mementoDir(mementoDir).classLoader(classLoader));
         LOG.info("Rebind complete");
         return r;
     }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/3dc4405c/software/base/src/test/java/brooklyn/event/feed/jmx/RebindJmxFeedTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/brooklyn/event/feed/jmx/RebindJmxFeedTest.java b/software/base/src/test/java/brooklyn/event/feed/jmx/RebindJmxFeedTest.java
index b9e1873..4e82e74 100644
--- a/software/base/src/test/java/brooklyn/event/feed/jmx/RebindJmxFeedTest.java
+++ b/software/base/src/test/java/brooklyn/event/feed/jmx/RebindJmxFeedTest.java
@@ -103,7 +103,7 @@ public class RebindJmxFeedTest extends RebindTestFixtureWithApp {
         EntityTestUtils.assertAttributeEqualsEventually(origEntity, SENSOR_STRING, "myval");
         assertEquals(origEntity.feeds().getFeeds().size(), 1);
 
-        newApp = rebind(false);
+        newApp = rebind();
         TestEntity newEntity = (TestEntity) Iterables.getOnlyElement(newApp.getChildren());
         
         Collection<Feed> newFeeds = newEntity.feeds().getFeeds();

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/3dc4405c/software/network/src/test/java/brooklyn/entity/network/bind/BindDnsServerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/network/src/test/java/brooklyn/entity/network/bind/BindDnsServerIntegrationTest.java b/software/network/src/test/java/brooklyn/entity/network/bind/BindDnsServerIntegrationTest.java
index f6f9fd8..b6b9aba 100644
--- a/software/network/src/test/java/brooklyn/entity/network/bind/BindDnsServerIntegrationTest.java
+++ b/software/network/src/test/java/brooklyn/entity/network/bind/BindDnsServerIntegrationTest.java
@@ -24,18 +24,13 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.annotations.Test;
 
-import com.google.common.base.Joiner;
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-
 import brooklyn.entity.basic.ApplicationBuilder;
 import brooklyn.entity.basic.Attributes;
 import brooklyn.entity.basic.EmptySoftwareProcess;
 import brooklyn.entity.basic.Entities;
 import brooklyn.entity.group.DynamicCluster;
 import brooklyn.entity.proxying.EntitySpec;
+import brooklyn.entity.rebind.RebindOptions;
 import brooklyn.entity.rebind.RebindTestFixture;
 import brooklyn.location.LocationSpec;
 import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
@@ -43,6 +38,12 @@ import brooklyn.policy.EnricherSpec;
 import brooklyn.test.EntityTestUtils;
 import brooklyn.test.entity.TestApplication;
 
+import com.google.common.base.Joiner;
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
+
 public class BindDnsServerIntegrationTest extends RebindTestFixture<TestApplication> {
 
     private static final Logger LOG = LoggerFactory.getLogger(BindDnsServerIntegrationTest.class);
@@ -65,7 +66,7 @@ public class BindDnsServerIntegrationTest extends RebindTestFixture<TestApplicat
         return app;
     }
 
-    @Test(invocationCount=1, groups = "Integration")
+    @Test(groups = "Integration")
     public void testRebindDns() throws Throwable {
         LocationSpec.create(LocalhostMachineProvisioningLocation.class);
         origApp.start(ImmutableList.of(new LocalhostMachineProvisioningLocation()));
@@ -73,7 +74,7 @@ public class BindDnsServerIntegrationTest extends RebindTestFixture<TestApplicat
         assertEquals(dns.getAttribute(BindDnsServer.ADDRESS_MAPPINGS).keySet().size(), 1);
         assertMapSizes(3, 1, 2, 1);
 
-        rebind(false, true, mementoDirBackup);
+        rebind(RebindOptions.create().mementoDirBackup(mementoDirBackup));
         try {
             dns = (BindDnsServer) Iterables.getOnlyElement(Iterables.filter(newApp.getChildren(), Predicates.instanceOf(BindDnsServer.class)));
             cluster = (DynamicCluster) Iterables.getOnlyElement(Iterables.filter(newApp.getChildren(), Predicates.instanceOf(DynamicCluster.class)));
@@ -92,7 +93,7 @@ public class BindDnsServerIntegrationTest extends RebindTestFixture<TestApplicat
             EntityTestUtils.assertAttributeEqualsEventually(cluster, DynamicCluster.GROUP_SIZE, 5);
             assertMapSizes(5, 1, 4, 1);
         } catch (Throwable t) {
-            // Failing in jenkins occassionally; don't know why and can't reproduce.
+            // Failing in jenkins occasionally; don't know why and can't reproduce.
             // Therefore dumping out lots more info on failure.
             LOG.error("Test failed; dumping out contents of original persistence dir used for rebind...", t);
             dumpMementoDir(mementoDirBackup);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/3dc4405c/software/nosql/src/test/java/brooklyn/entity/nosql/cassandra/CassandraDatacenterRebindIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/test/java/brooklyn/entity/nosql/cassandra/CassandraDatacenterRebindIntegrationTest.java b/software/nosql/src/test/java/brooklyn/entity/nosql/cassandra/CassandraDatacenterRebindIntegrationTest.java
index 0b53216..8f917cb 100644
--- a/software/nosql/src/test/java/brooklyn/entity/nosql/cassandra/CassandraDatacenterRebindIntegrationTest.java
+++ b/software/nosql/src/test/java/brooklyn/entity/nosql/cassandra/CassandraDatacenterRebindIntegrationTest.java
@@ -31,6 +31,7 @@ import org.testng.annotations.Test;
 
 import brooklyn.entity.proxy.nginx.NginxController;
 import brooklyn.entity.proxying.EntitySpec;
+import brooklyn.entity.rebind.RebindOptions;
 import brooklyn.entity.rebind.RebindTestFixtureWithApp;
 import brooklyn.entity.trait.Startable;
 import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
@@ -81,7 +82,7 @@ public class CassandraDatacenterRebindIntegrationTest extends RebindTestFixtureW
         Set<BigInteger> origTokens = origNode.getAttribute(CassandraNode.TOKENS);
         assertNotNull(origToken);
         
-        newApp = rebind(false, true);
+        newApp = rebind(RebindOptions.create().terminateOrigManagementContext(true));
         final CassandraDatacenter newDatacenter = (CassandraDatacenter) Iterables.find(newApp.getChildren(), Predicates.instanceOf(CassandraDatacenter.class));
         final CassandraNode newNode = (CassandraNode) Iterables.find(newDatacenter.getMembers(), Predicates.instanceOf(CassandraNode.class));
         

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/3dc4405c/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 364ef47..3556548 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
@@ -44,6 +44,7 @@ import brooklyn.entity.basic.Lifecycle;
 import brooklyn.entity.basic.SoftwareProcess;
 import brooklyn.entity.group.DynamicCluster;
 import brooklyn.entity.proxying.EntitySpec;
+import brooklyn.entity.rebind.RebindOptions;
 import brooklyn.entity.rebind.RebindTestFixtureWithApp;
 import brooklyn.entity.webapp.jboss.JBoss7Server;
 import brooklyn.location.LocationSpec;
@@ -131,7 +132,7 @@ public class NginxRebindIntegrationTest extends RebindTestFixtureWithApp {
         WebAppMonitor monitor = newWebAppMonitor(rootUrl, 404);
         final String origConfigFile = origNginx.getConfigFile();
         
-        newApp = rebind(false, true);
+        newApp = rebind(RebindOptions.create().terminateOrigManagementContext(true));
         final NginxController newNginx = (NginxController) Iterables.find(newApp.getChildren(), Predicates.instanceOf(NginxController.class));
 
         assertEquals(newNginx.getConfigFile(), origConfigFile);
@@ -175,7 +176,7 @@ public class NginxRebindIntegrationTest extends RebindTestFixtureWithApp {
         final String origConfigFile = origNginx.getConfigFile();
         
         // Rebind
-        newApp = rebind(false, true);
+        newApp = rebind(RebindOptions.create().terminateOrigManagementContext(true));
         ManagementContext newManagementContext = newApp.getManagementContext();
         final NginxController newNginx = (NginxController) Iterables.find(newApp.getChildren(), Predicates.instanceOf(NginxController.class));
         final DynamicCluster newServerPool = (DynamicCluster) newManagementContext.getEntityManager().getEntity(origServerPool.getId());
@@ -253,7 +254,7 @@ public class NginxRebindIntegrationTest extends RebindTestFixtureWithApp {
         final String origConfigFile = origNginx.getConfigFile();
         
         // Create a rebinding
-        newApp = rebind(false, true);
+        newApp = rebind(RebindOptions.create().terminateOrigManagementContext(true));
         ManagementContext newManagementContext = newApp.getManagementContext();
         final NginxController newNginx = (NginxController) Iterables.find(newApp.getChildren(), Predicates.instanceOf(NginxController.class));
         DynamicCluster newServerPool = (DynamicCluster) newManagementContext.getEntityManager().getEntity(origServerPool.getId());

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/3dc4405c/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 12b0843..61d92d7 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
@@ -34,6 +34,7 @@ import org.testng.annotations.Test;
 
 import brooklyn.entity.basic.SoftwareProcess;
 import brooklyn.entity.proxying.EntitySpec;
+import brooklyn.entity.rebind.RebindOptions;
 import brooklyn.entity.rebind.RebindTestFixtureWithApp;
 import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
 import brooklyn.test.EntityTestUtils;
@@ -95,7 +96,7 @@ public class JBoss7ServerRebindingIntegrationTest extends RebindTestFixtureWithA
         WebAppMonitor monitor = newWebAppMonitor(origServer.getAttribute(JBoss7Server.ROOT_URL));
         
         // Rebind
-        newApp = rebind(false, true);
+        newApp = rebind(RebindOptions.create().terminateOrigManagementContext(true));
         JBoss7Server newServer = (JBoss7Server) Iterables.find(newApp.getChildren(), Predicates.instanceOf(JBoss7Server.class));
         String newRootUrl = newServer.getAttribute(JBoss7Server.ROOT_URL);
         


[2/2] incubator-brooklyn git commit: This closes #309

Posted by al...@apache.org.
This closes #309


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

Branch: refs/heads/master
Commit: 0f2f63279b073e202badd62862599042a5cc9faf
Parents: d6a9aec 3dc4405
Author: Aled Sage <al...@gmail.com>
Authored: Tue Nov 18 10:15:05 2014 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Tue Nov 18 10:15:05 2014 +0000

----------------------------------------------------------------------
 .../rebind/RebindEntityDynamicTypeInfoTest.java |   5 -
 .../entity/rebind/RebindEntityTest.java         |  11 +-
 .../entity/rebind/RebindFailuresTest.java       |  24 +-
 .../brooklyn/entity/rebind/RebindFeedTest.java  |   6 +-
 .../brooklyn/entity/rebind/RebindOptions.java   |  92 +++++++
 .../entity/rebind/RebindTestFixture.java        | 136 +++++-----
 .../brooklyn/entity/rebind/RebindTestUtils.java | 249 ++++++++++++++++---
 .../transformer/CompoundTransformerTest.java    |   8 +-
 .../access/PortForwardManagerRebindTest.java    |   2 +-
 ...lusterDatabaseExampleAppIntegrationTest.java |   3 +-
 .../entity/pool/ServerPoolRebindTest.java       |   3 +-
 .../event/feed/jmx/RebindJmxFeedTest.java       |   2 +-
 .../bind/BindDnsServerIntegrationTest.java      |  19 +-
 ...assandraDatacenterRebindIntegrationTest.java |   3 +-
 .../proxy/nginx/NginxRebindIntegrationTest.java |   7 +-
 .../JBoss7ServerRebindingIntegrationTest.java   |   3 +-
 16 files changed, 412 insertions(+), 161 deletions(-)
----------------------------------------------------------------------