@Test
  public void testInvokeStopEntityOnShutdown() throws Exception {
    BrooklynShutdownHooks.invokeStopOnShutdown(entity);
    BrooklynShutdownHooks.BrooklynShutdownHookJob job =
        BrooklynShutdownHookJob.newInstanceForTesting();
    job.run();

    assertTrue(entity.getCallHistory().contains("stop"));
  }
  // Should first stop entities, then terminate management contexts
  @Test
  public void testInvokeStopEntityAndTerminateManagementContextOnShutdown() throws Exception {
    BrooklynShutdownHooks.invokeTerminateOnShutdown(managementContext);
    BrooklynShutdownHooks.invokeStopOnShutdown(entity);
    BrooklynShutdownHooks.BrooklynShutdownHookJob job =
        BrooklynShutdownHookJob.newInstanceForTesting();
    job.run();

    assertTrue(entity.getCallHistory().contains("stop"));
    assertFalse(managementContext.isRunning());
  }